Udi
Udi

Reputation: 1110

Returning REST 400-Bad Request with additional information

Hey, I have a REST based server, and in some cases I want to return a failure code (400 for example), BUT, I wish to add additional URL. Something like - "failure, but here's what you can do now.." Is there any good convention to do so? Is it even a good idea to return error with additional information?

Thanks, Udi

Upvotes: 5

Views: 2066

Answers (1)

fumanchu
fumanchu

Reputation: 14559

It is always a good idea to return additional information in an error message. The HTTP spec itself says so: "Except when responding to a HEAD request, the server SHOULD include an entity containing an explanation of the error situation, and whether it is a temporary or permanent condition. These status codes are applicable to any request method. User agents SHOULD display any included entity to the user."

One thing to watch out for: some versions of Internet Explorer will not show the user your additional error information if it is not a certain number of bytes. Make sure your response entities for error messages are at least 512 bytes to be sure.

Upvotes: 3

Related Questions