Dynamic Path to Success and Error fields JSON
Hello Community!
Can someone help with this path to success field?
I've got the below body 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"
}
}
}
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.
results.{{order_id}}.success
Regardless I cannot find a working path!
Note: "ABC123" is the order id on the request.
Thanks!
Comments
Fabio Dias, 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:
If this isn't a 51st attempt or it takes you down another dead end, I'd try Office Hours next.
Hi Stephen Brandt,
I'm trying to setup the correct responses by the system, at the moment even correct responses give an error.
This is where I'm trying to setup the paths.
Unfortunately, without luck thus far.
Thanks,
Fabio Dias
Fabio Dias, 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,
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.
Fabio Dias: 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:
Hi Stephen Brandt,
Thanks for all the help thus far!
The structure of my records as below in the "Build relative URI" function.
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.
Thank you,
Fabio Dias
Hi Fabio Dias,
Thanks so much for providing this information. We've entered a support ticket on your behalf so that you can get this problem resolved quickly.
Hi All,
Has this been resolved?
I have the same problem -- Celigo raises
although I just need to access a simple field called "Status" in the root.
Also, looking at the last response above - it looks like Celigo doesn't recognize the response as a valid JSON, which is also my case.
Thanks
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?
Please sign in to leave a comment.