api - RESTful way to preallocate an ID -
for reasons application needs have api flows like:
- client calls server id new resource.
- then user spends while filling out forms resource.
- then user clicks save (or not...), , when client saves writing
/myresource/{id}
what restful way design this?
how should first call like? on server side, it's matter of generating id , returning it. has side effects (increments sequence , "reserves space"), doesn't explicitly create resource.
if understand correctly, 3rd call should put because creates known uri.
one way is:
- client
posts empty body/myresource/ - server answers status code
302 (found)locationresponse header set/myresource/newresourceid(to indicate id / uri should used create resource) - client
puts new resource/myresource/newresourceidonce user done filling form.
seems restful enough. ;)
Comments
Post a Comment