Layer7 API Management

 View Only
Expand all | Collapse all

Pass default backend service failure response to the consumer app

  • 1.  Pass default backend service failure response to the consumer app

    Posted Jun 25, 2020 10:03 AM
    Hi All,

    I have a service in the gateway with a backend URL configured in 'Route Via HTTP' assertion in that service. I am testing a negetive scenario where I am passing a 'GET' method to that backend service URL where as it expects a 'POST' method. Below is the error I am getting in Postman:-

    Status: HTTP 500 Internal Server Error
    Body:-
    {
    "Code": "InternalServerError",
    "Message": "Something went wrong on the API gateway or micro-service.",
    "Errors": [
    {
    "ErrorCode": "UK.OBIE.UnexpectedError",
    "Message": "An unexpected error occurred."
    }
    ]
    }

    But the backend service is actually sending a proper response Json as below:-
    HTTP 405
    {"errorCode":"VALIDATION-004","errorMessage":"Request method 'GET' not supported","applicationName":"XXXXXXXX"}

    Please help me how can I route back this above Json response back to the requestor.

    The context is we have to pass target web service response (success or failure) back to the client application without any modification or customization.

    Regards,
    Rohan

    ------------------------------
    [Technology Analyst]
    [Infosys Limited]
    ------------------------------


  • 2.  RE: Pass default backend service failure response to the consumer app
    Best Answer

    Posted Jun 25, 2020 10:42 AM
    Hi Rohan,

    Open your policy, go to Route via http --> other tab and tick "never fails as long as target returns an answer". Save the policy and it should return response sent by target web service 

    ------------------------------
    Technology Lead
    Infosys Limited
    ------------------------------