api - RESTful way to preallocate an ID -


for reasons application needs have api flows like:

  1. client calls server id new resource.
  2. then user spends while filling out forms resource.
  3. 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) location response header set /myresource/newresourceid (to indicate id / uri should used create resource)
  • client puts new resource /myresource/newresourceid once user done filling form.

seems restful enough. ;)


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

How to get multiresult with multicondition in Sql Server -