英文:
how to change error message for not allowed htttp methods when calling an API resource in wso2 API manager?
问题
我在WSO2 API Manager中创建了一个REST API,为例子的"delivery"资源仅分配了POST方法来调用此API资源。默认情况下,当使用其他HTTP方法调用此API时,API Manager会抛出以下响应:
<am:fault xmlns:am="http://wso2.org/apimanager">
<am:code>405</am:code>
<am:type>Status report</am:type>
<am:message>Runtime Error</am:message>
<am:description>Method not allowed for given API resource</am:description>
</am:fault>
在某些HTTP方法,如COPY方法中,它会抛出400 Bad Request。首先,我想在响应中不显示上面的消息,只返回状态码,而不返回响应消息。其次,只对POST方法之外的所有HTTP方法显示405 Method Not Allowed。
英文:
I created a rest api in wso2 api manager publisher add add a resource for example delivery and only assign post method for calling this api resource , by default when use other http methods for calling this api , api manager throws below response :
<am:fault xmlns:am="http://wso2.org/apimanager">
<am:code>405</am:code>
<am:type>Status report</am:type>
<am:message>Runtime Error</am:message>
<am:description>Method not allowed for given API resource</am:description>
</am:fault>
and in some http methods like COPY it throws 400 bad request ,first I want to don't show above message in response and only give back the status code and nothing in response message
and second show 405 method not allowed for all http methods except POST method.
答案1
得分: 1
你可以修改默认的故障序列以更改消息。请查看此文档。
英文:
You can modify the default fault sequence in order the change the message. Take a look at this document.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论