添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

I have a generic REST service layer written to Java modules which can be plugged in. If any of the desired operation is not supported by a Module (GET/POST/PUT/DELETE of a Resource), the module throws java.lang.UnsupportedOperationException or an equivalent Exception Type that I have.

So, can I return a HTTP 501 Error Code to the client in this case?

A request was made of a resource using a request method not supported by that resource; for example, using GET on a form which requires data to be presented via POST, or using PUT on a read-only resource.

501 is reasonable:

The server either does not recognise the request method , or it lacks the ability to fulfill the request.

but I would keep it for operations that you plan to implement in the near future.

Thanks Tomas. Just to clarify, if a client is trying to create a resource /rest/module_name/Person and create() is not supported by the module identified by "module_name", it is treated as a client request problem and thrown a 405 rather than a server side problem by returning 501? The reason I ask is that, 4XX are client related error codes whilst 5XX are server related. Anil G Jul 10, 2012 at 7:40 @BlueDiamond: well, is it you (API provider) doing something wrong (5xx) or the client is using the API incorrectly (4xx)? Tomasz Nurkiewicz Jul 10, 2012 at 7:47

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question . Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers .