Unable to read exact error response body from HTTP Request connector in Mule 4.2
Asked Answered
H

3

5

We are posting PO data to Oracle instance in XML format using REST API. In a failed case, it is just a printing message from error.description example "HTTP POST on resource 'https://hostname:post/fscmService/PurchaseOrderServiceV2' failed: internal server error (500)." Now the request is to print the exact error message from Oracle Cloud ERP. When we run the same test case from Postman we can see the exact error message in the response body and I am trying to print the same response in mule logger and would like to send the same as response payload but not able to get it.

I tried to debug Mule flow and stoped in Exception handler "On Error Propagate" and looked at all variables to see actual error response but didn't find. Please advise!

Please find below screenshots for reference.

enter image description here

enter image description here

enter image description here

Hydrogenous answered 19/11, 2019 at 13:51 Comment(0)
B
9

You can access the failed response body via error.errorMessage.payload.

Beauty answered 19/11, 2019 at 14:25 Comment(5)
I am trying the same with until successful functionality and 'error.errorMessage.payload' is null in error handler.Hydrogenous
Code: <until-successful maxRetries="3" doc:name="Until Successful" doc:id="ffee4cdf-8984-4d7a-a377-bcacdc4d73e9" millisBetweenRetries="10000"> <http:request method="POST" doc:name="Test" doc:id="0e2c6aad-a531-4854-89d6-b360fdf6cb12" config-ref="HTTP_Request_configuration" path="/fscmService/PurchaseOrderServiceV2" outputMimeType="text/xml" /> </until-successful>Hydrogenous
Hi Afelisatti, Could you please advise on this issue?Hydrogenous
Could you update the debugging view image showing what there is within the error in the muleMessage field? I don't see the error handler on the code snippet shared above and that's the only place where you get access to the error variable.Beauty
Updated debugging images inside until successful and out side until successful.Hydrogenous
H
3

Here is the fix.

With out Until-Successful: We can access the failed response body via : error.errorMessage.payload or error.muleMessage.typedValue

With Until-Successful: We can access the failed response body via : error.exception.cause.errorMessage.payload or error.exception.cause.errorMessage.typedValue

Thank you.

Hydrogenous answered 20/11, 2019 at 10:47 Comment(2)
Please keep in mind that error.muleMessage.typedValue is not supported by the Mule APIs, it only works because it uses reflections to access the values.Beauty
Thank you for your support Afelisatti :).Hydrogenous
M
0

With Until-Successful, I see error.exception.cause = null, but see error.muleMessage.typedValue containing the failed response body.

Manifesto answered 17/11, 2021 at 9:20 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.