generating 405 in API proxy

Not applicable

Hi Devs,

I have two conditional fows PUT and GET , we want to throw back 405, if request for Delete or POST method are sent, do we need to create two conditional flow with 2 raise fault in them to handles those scenario in API proxy ?

Can this be handled by fault rules instead of 2 conditional flows?

In genaral, what is the best place to handle 405 error ; at backend server or at api proxy ?

Thanks

Solved Solved
0 3 985
1 ACCEPTED SOLUTION

Hi @ansmayank,

For allowing only the exposed resources and methods you can use a generic unknown resource found flow without a condition as per below code:

<Flow name="UnknownResource">
    <Request>
        <Step>
            <Name>RF-ResourceNotFoundFlowFault</Name>
        </Step>
    </Request>
    <Response/>
</Flow>

Where in RF-ResourceNotFoundFlowFault you can raise a fault with 405 or 404 error.

Make sure this is the last flow in your proxy. If none of the flow conditions match then this flow will be executed resulting in a resource not found error.

Cheers!

View solution in original post

3 REPLIES 3

Hi @ansmayank,

For allowing only the exposed resources and methods you can use a generic unknown resource found flow without a condition as per below code:

<Flow name="UnknownResource">
    <Request>
        <Step>
            <Name>RF-ResourceNotFoundFlowFault</Name>
        </Step>
    </Request>
    <Response/>
</Flow>

Where in RF-ResourceNotFoundFlowFault you can raise a fault with 405 or 404 error.

Make sure this is the last flow in your proxy. If none of the flow conditions match then this flow will be executed resulting in a resource not found error.

Cheers!

wow, that was simple 🙂 . so in short we can create a default flow which would be a flow without a condition to handle all other scenario.

Interestingly, I notice that adding this flow causes

405 for urls not matching condition but allowed methods . These transactions appearing in trace.

404 for methods not allowed (like Delete, POST) . These transactions don't appear in trace.