What error message to return in a REST API with HTTP status code 405?
If at all any error message should be returned with status code 405, what should it say? I suspect we should not return any, but just to make sure are there any best practices for this?
Given that 405 means Method not allowed, it's pretty obvious to anyone familiar with HTTP or other RESTful APIs what it means.
However, not all of your customers writing software with your APIs might have that prior experience, so it might be worth returning a message in the response that says something like, "This resource does not support the HTTP method PUT."
You might also want to include a hint in the returned message to tell the user to call OPTIONS to find out which methods are supported, assuming you implement it as such.
Given that 405 means Method not allowed, it's pretty obvious to anyone familiar with HTTP or other RESTful APIs what it means.
ReplyDeleteHowever, not all of your customers writing software with your APIs might have that prior experience, so it might be worth returning a message in the response that says something like, "This resource does not support the HTTP method PUT."
You might also want to include a hint in the returned message to tell the user to call OPTIONS to find out which methods are supported, assuming you implement it as such.