Parsing XML on Errors

So, I'm sending an API call to Excalibur WMS, and on error, it returns the following XML:

Since it doesn't return JSON, I can't put it into the mock output, nor does it get passed to later steps in the process, even when error handling is set to Proceed to the next application regardless, and the Override media type for error responses = JSON or Plain Text.

My goal is to extract this section of the response and put it into an email to the CSR.

Unfortunately, since the XML isn't parsing, I don't get any data back to be put into the response mapping.

I worked with @christran, and he told me to ask the community as well, so what do y'all think?

You have the "Override media type for error responses" set to XML? Plain text is always a backup as well. Can you share your setup?

Hello Tyler,

These are the options I have:

Setup:

That must be because you already have media type as XML on your connection. If you click populate with live data, what happens? It should be parsing it into json and putting it into the _json field.

I get this

Also tried post response mapping to _json.message with Chris and that didn't give me anything either.

And when I put the parsed output into the mock output, then I get this set of errors

image

Can you map to just _json in response mapping and see what you get during run?

Tried that

No, not to _json.message, just to _json.

Comes out as blank. I also tried clearing the the Mock Data and running in test and it just reverts to the "replace me" text in the response mapper.

Yeah, can you map it and force a failure in flow to see what you get?

I did, I don't get anything.

Can you invite me to the account? It's there in my testing.

Invite Sent

I looked into it and see what's going on. We have a backlog item to populate _json with the response body even when there's an error. Right now, the XML response is getting placed into errors.0.message as raw XML.

To work around this, I mapped errors.0.message back into your data, then used Celigo’s internal API to convert the XML to JSON. This is an undocumented endpoint (which we might want to officially document now) that accepts XML and returns JSON.





2 Likes

That's working! Thank you for all of your help!