rest - HTTP POST response Location header when creating multiple resources -


the http/1.1 standard states if post operation results in creation of resource, response should include location header address of new resource.

if resource has been created on origin server, response should 201 (created) , contain entity describes status of request , refers new resource, , location header (see section 14.30).

and in section 14.30,

for 201 (created) responses, location of new resource created request.

now suppose api allows batch creation of resources posting array collection resource url. example:

post /books [     {         "name": "the colour of magic",         "published": "1983"     },     {         "name": "the light fantastic",         "published": "1986"     } ] 

since 2 \book\{bookid} resources have been created, should value of location header in case?

the question http post response after multiple new resource creation? similar, asks response entity, not headers (and unanswered).

i know answer late party believe best solution create new batches resource uuid identifier return list of book urls added using url this:

http://api.example.com/batches/{uuid} 

e.g.

http://api.example.com/batches/2b9b251f71a4b2901d66e04725bc0c9cb5843c74 

then post or put can return above url on it's location: {url} header , 201 - created status code.

if get url list of urls created in batch other info batch such uuid , time/date created.

{   "uuid": "2b9b251f71a4b2901d66e04725bc0c9cb5843c74",   "datetime": "2005-08-15t15:52:01+00:00",   "books": [     "http://api.example.com/books/the-colour-of-magic",     "http://api.example.com/books/the-light-fantastic"   ] } 

those resources have ttl of hour or month, whatever choose. of live forever if want; whatever use-case requires.


Comments

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

gradle error "Cannot convert the provided notation to a File or URI" -

ios - Possible to get UIButton sizeThatFits to work? -