Reputation: 879
Is it RESTful to return a slightly different object, like the one which was send to the server, on a POST/PUT?
Example:
The client sends (POST/PUT) an Order
to the Server to create an Order. The Server sends a Response Object, lets call it OrderResponse
which contains the Attributes of the created Order
plus some different informations like delivery time, terms of payment and so on. Is this RESTful or should i just return an OrderId and offer a new Service, where the Client could retrieve the OrderResponse
?
Edit:
I am not able to give the Client an URL to the new Order, because the Order isnt saved in a Database. My application sends the Order via Messaging to a third party system, where I cant read it from, but the third party system sends me some additonal informations, which I add to the OrderResponse
.
Upvotes: 1
Views: 315
Reputation:
I would not consider Order
and OrderResponse
to be different Resources. They are of the same type. It is just that the client can't and shouldn't know all the details of this Resource. The exact ID is assigned by the server, for example.
Location
header in the HTTP response to the POST
request that contains the URI of the creates Order
.Order
and this URI more complete that the one POST
ed by the client.Upvotes: 2