문제

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 :)

도움이 되었습니까?

해결책

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".

다른 팁

200 is the appropriate status code assuming the PUT only did an update and did not create a resource.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top