Layer7 API Management

Expand all | Collapse all

Is it possible to change default (error) responses like the 204 No Content?

  • 1.  Is it possible to change default (error) responses like the 204 No Content?

    Posted Feb 01, 2018 04:35 AM

    Hi all,

    are there any possibilities to adjust the default responses from the API Gateway for example the "204 No Content"? Means can we adjust the HTTP status code or at least the body of the response?

    And if so, how and where can this be done?

    Thank you!

     

    Regards,

    Stefan



  • 2.  Re: Is it possible to change default (error) responses like the 204 No Content?

    Posted Feb 01, 2018 05:25 AM


  • 3.  Re: Is it possible to change default (error) responses like the 204 No Content?

    Posted Feb 01, 2018 05:55 AM

    Hi sharkkae,

    thank you for the quick response. No I mean (error) responses, which will be sent BEFORE the policy is triggered.

    For example the 204 will be issued, because there is no match in any of the configured policies. So a policy assertion will not help here. Therefor I assume it's somewhere specified in the overall configuration of the API gateway.

    Thanks again.

     

    Ciao Stefan



  • 4.  Re: Is it possible to change default (error) responses like the 204 No Content?

    Broadcom Employee
    Posted Feb 02, 2018 12:57 PM

    Apologies because I dont get what triggers the 204. But if its in pre policy processing you likely could do something in 

    Global Policy Fragments - CA API Gateway - 9.1 - CA Technologies Documentation 

    Message received. Would be pre-policy processing, before our service resolver. So assuming based on your statement this may do the trick.

     

    Unless its even earlier then this and at the listen port level before api management has gotten the message itself.

    If its at the listen port level, then you might be able to do it with an advanced apache/tomcat setting but I dont know of anything specifically that you can configure for that.

    Thanks.



  • 5.  Re: Is it possible to change default (error) responses like the 204 No Content?

    Posted Feb 20, 2018 07:57 AM

    Hi Charles,

    sounds like a plan, but how do I validate the incoming URL (or at least the beginning of the path) against all configured policies? Which assertion can handle this? Something like a lookup, but which variable contains all configured policy resolution paths?

    If that's not possible, then I think the global policy fragment isn't the solution here.
    But isn't this 204 response not somewhere configured in a configuration file or in some variable?

    Thank you!

     

    Ciao Stefan



  • 6.  Re: Is it possible to change default (error) responses like the 204 No Content?

    Broadcom Employee
    Posted Feb 08, 2018 07:29 PM

    Dear StefanKlotz,

    We already have an idea to customize the default fault response.

    JSON Fault Reponse 

     

    Regards,

    Mark



  • 7.  Re: Is it possible to change default (error) responses like the 204 No Content?

    Posted Feb 21, 2018 08:24 AM

    Hi StefanKlotz

     

    You can create a Global Policy Fragment as suggested by Charles_Lilienkamp. And in that fragment you define a "Customize Error Response" assertion. 
    When you now go to a not existing url on the gateway, the error message and error code define in this assertion will be returned to the client. So as I see it, there is no need to lookup all configured policy resolution paths. 


    Kind regards
    Samuel



  • 8.  Re: Is it possible to change default (error) responses like the 204 No Content?

    Posted Feb 21, 2018 09:06 AM

    Hi Samuel,

    thanks for your response, but this doesn't seem to work. I created a global policy fragment from type "message-received" and used the "Customize Error Response" assertion, but I still get a 204 No Content.

    But even if this method would work, the "Customized Error Response" would be used for ALL issue, right? Or can this be differentiated? I'm just looking for the error, when no custom resolution path will be found.

    Thank you!

     

    Ciao Stefan



  • 9.  Re: Is it possible to change default (error) responses like the 204 No Content?
    Best Answer

    Posted Feb 27, 2018 10:42 AM

    Hi all,

     

    You can use a catch all policy, which will be called upon every time a service is not called on the Gateway. You can set this up by creating a publishing a new Web API and give the Gateway URL an endpoint of an asterisk (*). You can then edit this policy and use the return template to customize your response for error 204, or play around with the "Customize Error Response" assertion.

     

    Kind Regards,

    Anwar



  • 10.  Re: Is it possible to change default (error) responses like the 204 No Content?

    Posted Mar 01, 2018 02:59 AM

    Hi koran,
    thank you for your support and yes that's not only the solution, but also the root cause of our behavior. Because we already have this "catch all" policy, but nobody was aware of it (had some long historical background).

     

    Ciao Stefan