When Updating a resource, what HTTP Status Code is returned when the update is successful?

Pure.Krome picture Pure.Krome · May 8, 2012 · Viewed 13.6k times · Source

So i've got a website that accepts an HTTP-PUT for a particular resource, eg. /contact which will allow the consumer to update a contact, assuming they have passed validation.

So I update the record, all is great .. and now I need to return something to the consumer.

What's the HTTP Status Code I should be returning?

If this was an HTTP-POST (ie. Creating a -new- resource), then I would return an 201 Created and add a Location header attribute.

But .. I can't find any clues about what to do for an Update.

Cheers :)

Answer

fumanchu picture fumanchu · May 8, 2012

200 is especially appropriate if you are returning a representation of the action (although the work-in-progress-but-nearing-last-call "HTTP bis" oddly doesn't mention PUT in its description of 200 OK).

If you're not returning any sort of representation, use 204 No Content to indicate to the client that it doesn't need to change its current "document view".