Skip to main content

Dynamic Path to Success and Error fields JSON

Comments

6 comments

  • Stephen Brandt Documentation Manager Community moderator
    Engaged
    Great Answer
    Top Contributor
    Celigo University Level 3: Master

    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: 

    {{#each results}}{{#if @first}}{{success}}{{/if}}{{/each}}

    If this isn't a 51st attempt or it takes you down another dead end, I'd try Office Hours next. 

    0
  • Fabio Dias
    Engaged

    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

    0
  • Stephen Brandt Documentation Manager Community moderator
    Engaged
    Great Answer
    Top Contributor
    Celigo University Level 3: Master

    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,

    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. 

    0
  • Stephen Brandt Documentation Manager Community moderator
    Engaged
    Great Answer
    Top Contributor
    Celigo University Level 3: Master

    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:

    0
  • Fabio Dias
    Engaged

    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

    0
  • Courtney Jordan Experience Strategy & Design Director Community moderator
    Celigo University Level 4: Legendary
    Awesome Follow-up
    Top Contributor

    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. 

    0

Please sign in to leave a comment.