I have a back-end service that creates unique identifiers for resources.
The general idea is that resources are saved and versioned, so you can perform:
GET http://service/sales/targets/7818181919/latest
or
GET http://service/sales/targets/7818181919/4 for version 4, and so on.
My question is about the most correct way to upload these resources in the first place.
How about:
PUT http://service/sales/targets/ returning 303 See other /service/sales/targets/
It seems a little wrong as you should PUT and GET from exactly the same place using a resource-oriented interface, but I can’t think of a better option. Any ideas?
You should set the Location header when you POST or PUT the resource. The target for the POST should be the appropriate ‘container’ resource (http://service/sales/targets/ in your case)
See here for more details on the HTTP Headers. I’ve quoted the relevant section below. Hope that helps …
Chris