{ "success": true, "results": { "ABC123": { "success": false, "message": "The order could not be marked as dispatched because it has a status of \"Dispatched\"", "errorcode": "InvalidOrderStatus" } } }
I would expect the path to be..
$.results..success
But this doesn't work and I also tried about 50 different combinations, including trying to include handlebars or using XPath and nothing seems to work.
With handlebars I tried the below, where {{order_id}} is available on the request side.
@fabiodias, in this forum I'm not able to picture what the value of order_id is in your flow compared to where you need to access the response success value.
Are you trying to get the value of success, or do you need to provide the path to it?
To check the value, you could try looping through the results array:
@fabiodias, your question is a bit more complex than the handlebars solution, which wouldn't apply here.
First of all, it looks as though you're trying to apply JSONPath expressions, which aren't yet supported in integrator․io. That is, you can't specify something allowed elsewhere, like $.results[0].success.
My next observation is that the correct path for success in this case looks to be simply,
success
at the root, which is in fact "true" in your sample response.
[REVISED] In the import shown above, you should be able to retrieve the value of {{order_id}}, depending on its structure in your flow's records. However, that might not be useful if there are zero or more than one records that produced an error.
@fabiodias: I also reached out to a solutions consultant, who advises that nonstandard error responses aren't as dynamic as what you're hoping to account for. Check out the following article, if you're comfortable with JavaScript:
Could I reference order_id somehow? I tried {{order_id}} and {{record.order_id}}, unsuccessfully... example below.
Message: "Unable to extract paths from response body using path: results.{{record.order_id}}.success, Response: {\"success\":true,\"results\":{\"ABC123\":{\"success\":false,\"message\":\"The order could not be marked as dispatched because it has a status of \\\"Dispatched\\\"\",\"errorcode\":\"InvalidOrderStatus\"}}}"
The reason why I need the nested success field instead of the root one is because if there is a fulfilment error, it is on the nested success field, not on the root one. The root success is just for the connection success/failure.
It would be great if possible to avoid the postSubmit hook as I tend to find that more unexpected behavior happens and this seems to be a fairly simple thing to do.
Milcho, the scenario you've mentioned is slightly different and there should not be an issue. Could you share a screenshot of the sample response and configuration you're using so that the team can look into the matter?