'Integromat - How to parse error message from custom API service
I set up a custom app on Integromat that integrates a custom API for a delivery service.
Some of the module, sometime, got an error due to wrong address (es. wrong zip code). The API response's body has the specific problem in the body, but during the scenario, if the error happens, I only got the Integromat error which has no extra data at all, so I have to rerun manually the scenario using Integromat dev tools to read what was the problem.
Reading here Error handling with different error structures in my custom Integromat app, I figure out to use a custom function to parse the response body
function parseErrorMessage(body) {
if ('string' === typeof body.data)
return JSON.parse(body.data)
}
but I didn't understand how to catch the 3 fields that hold the data: errorFieldCode, errorTypeCode and errorMessage.
The function is called in the module with this snippet:
"response": {
"output": "{{body}}",
"error": "{{parseErrorMessage(body)}}"
}
I would like to use those data in a module in the error handling path.
How should I edit the function above to parse the body into the 3 field it contains?
Here is a screenshot where you can see the module having an error, the response body with the info I need to understand the error immediately (violet border), and the output of the module instead (orange border).
I am not able to manipulate the response body, since for Integromat is and error and it populates the output field with its data.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
