Replies: 3 comments
-
501 refers to the http method specifically, and should not be used here. It would also indicate a server error, which this is not, as the client is requesting the wrong resource. A 404 is correct, as it refers to the resource that the URL is pointing to (an entry) and that this resource cannot be found. |
Beta Was this translation helpful? Give feedback.
-
501 (Not Implemented) could also be used to indicate "endpoint not found" whereas 404 can refer to "content not found" — Either way, the more informative the response, the better. |
Beta Was this translation helpful? Give feedback.
-
This was mentioned on Slack... 404 could also be misinterpreted as "endpoint not found" |
Beta Was this translation helpful? Give feedback.
-
The Element API plugin is great! But it seems to have a notable shortcoming...
If the endpoint tries to retrieve an entry that has been disabled or deleted, it will respond with a 404 error. This is counter-intuitive... Whatever is calling the endpoint will be expecting some sort of JSON response.
It would be great if we could output a custom error message instead! (In JSON format, of course.)
Possible workarounds have been discussed on Stack Exchange, although none of them seem like a sufficient (non-hacky) fix for this problem...
http://craftcms.stackexchange.com/questions/13177/element-api-plugin-return-message-when-no-results-are-found
Beta Was this translation helpful? Give feedback.
All reactions