Layer7 API Management

  • 1.  Customized Error Message for Unallowed HTTP Methods

    Posted Dec 21, 2016 11:38 AM

    I have published an API with only POST and PUT methods. If someone tried to invoke the same API with GET method, Gateway responds with 'Unhandled exception'. 

     

    Is there a way to send customized error message for this kind of issues?

     

    Regards

    Kareem



  • 2.  Re: Customized Error Message for Unallowed HTTP Methods

    Posted Dec 21, 2016 12:57 PM

    Hi Kareem,

     

    I do not believe there is a way for this to be customized at this point in time. The workflow would be Listen Port > Service Methods > Policy Execution. Any calls to a service which doesn't support the method in the request will fail to proceed to policy execution which is where you would normally make all the customizations for various error responses inside of a policy. As this falls outside the policy, I don't think it can be customized yet. But this would make a great feature request in the CA API Management Community, filed as an "Idea".

     

    And if I'm wrong, hopefully someone else will correct me. :-)

     

    Sincerely,

     

    Dustin Dauncey

    Sr Support Engineer, Global Customer Success

    Email: Dustin.Dauncey@ca.com

    Phone: +1 800 225 5224 ,48385

    Phone if outside North America - https://tinyurl.com/CAContactSupport

    CA API Management Community: https://tinyurl.com/CAAPIMCommunity

     



  • 3.  Re: Customized Error Message for Unallowed HTTP Methods

    Posted Dec 21, 2016 01:14 PM

    You could 'Allow' all methods via the Service Property panel, and then have a Encap, at the top of the policy, checking all allowed methods ( which you select via the Encap input ) and generate a custom error response if other un-approved methods are used ?

     

    slightly more work, but will accomplish what you are needing.



  • 4.  Re: Customized Error Message for Unallowed HTTP Methods

    Posted Dec 22, 2016 03:01 AM

    In a similar way as Doyle described, we have customers that have set up a catch all policy (listens on /*) where all requests will go which can not be handled by a specific service. This also gives you an option to create custom error responses for specific cases.



  • 5.  Re: Customized Error Message for Unallowed HTTP Methods

    Posted Jan 18, 2017 11:56 AM

    Unfortunatly service resolution does not take into consideration HTTP method, so requests for a method not allowed to a web API will not fail over to the catch-all.  I do similar to what Doyle suggests and enable all methods for non-SOAP services then return a method not allowed error for methods that are not handled.

    While I think Edward's solution would also work, I would avoid it because it would add overhead to all services and increase load on the database (also I try to avoid surfacing access to the database within the gateway as not all of my policy developers are administrators).



  • 6.  Re: Customized Error Message for Unallowed HTTP Methods



  • 7.  Re: Customized Error Message for Unallowed HTTP Methods

    Posted Jan 05, 2017 04:09 PM

    It is possible, but you have to do it in the message-received global policy. You can query the database and give a custom response. We use it for giving a nice HTTP 405 result.

    The query we use is: SELECT http_methods FROM ssg.published_service WHERE hex(goid) = ${resolvedservice.oid};

    Make sure to cache the values to prevent a lot of database access.

     

    Here is more information.

     

    https://www.ca.com/us/services-support/ca-support/ca-support-online/knowledge-base-articles.TEC1272939.html?intcmp=searc…