httpresponseazure-logic-appshttp-response-codeshttpresponsemessage

Azure Logic App - Get Response Body with 500 Internal Server Error


Is there any way to get the response body in Azure Logic App even when we get 500 Internal Server Error? I have made the Logic App in a way that I'm setting the response code to 500 on an issue, and I'm adding some error related information in the response body. I tried returning 504 Gateway timeout as well, in case of a timeout issue I could face, but I'm always receiving a null response body in case of non-200 response codes. If we are not able to see the response body in case of an error by design, is there a better way to set and fetch error related information from the response object?


Solution

  • Yes you can get the response body in Azure Logic App by adding the response action. According to this Add a Response action section of the Microsoft document.

    When you use the Request trigger to handle inbound requests, you can model the response and send the payload results back to the caller by using the built-in Response action.

    Following steps would help you to get the response body.

    responseAction

    I would suggest to read the Receive and respond to inbound HTTPS requests in Azure Logic Apps document for more information.

    Alternatively you can also create alerts whenever HTTP 500 errors occur in your App and use Application Insights to view it using Azure Monitor. I would also suggest to read this Handle errors and exceptions in Azure Logic Apps Microsoft document for more information.