Reputation: 897
I have a request from the client - when the user performs an action, there can be 3 actions:
There does not seem to be a way for REST APIs to return an indication that the action completed successfully with some helpful information that further action might fail.
Thanks
Upvotes: 5
Views: 2927
Reputation: 7744
You didn't mention which HTTP method you are preparing for. Using GET
should of course not modify anything, so I'm assuming it's either POST
or PUT
.
For POST
, the response should be 201 Created. There should be a Location
header line indicating the resource that was created.
For PUT
, the response should be 200 OK.
In both cases, you can return a content body, as others suggested. This body can be some status information about the current state of whatever resource you are using. Note, that this status information might be reachable explicitly by some other URI, so it can share a mime-type
with that "status" resource.
Upvotes: 2
Reputation: 116
HTTP response codes are limited and I think, those to be used to indicate any generic response. To have application specific response codes or response strings, it is better to have application level response codes to be communicated via HTTP response payload.
Upvotes: 2
Reputation: 12942
REST is using HTTP methods and HTTP status to represent the status of reply, by checking HTTP status I can find code 203 I think it could be suitable for your 3rd case :
203 Non-Authoritative Information (since HTTP/1.1) The server successfully processed the request, but is returning information that may be from another source.
Upvotes: 2