E9.2 Orchestration REST API JSON Connector Output

Rhett

Member
Hello all. I'm working on a connector in Orchestration Studio and successfully call a POST API. My issue is mapping the return JSON to Output. Below is a simple example of the JSON data. How do I map the MonetaryValue to an output (seen in print screen below)? Any guidance is much appreciated.

1661473821042.png

1661473939003.png
Tools Release 9.2.4.4

Thanks,
Rhett
 
I maybe wrong but I thought it was something like this
"MonetaryValue ": "${MonetaryValue }"
And the $ part forces the Orch to recognise it

But I also found this
 
I maybe wrong but I thought it was something like this
"MonetaryValue ": "${MonetaryValue }"
And the $ part forces the Orch to recognise it

But I also found this
John, thank you for your response. I've tried your suggestion and several other iterations along those lines without success. Below is the Output I began with. However, when I use the ${"x"}", it prompts for the value as an input variable although it is setup in the Output.

{"ShipmentResponse": {"Response": {NegotiatedRateCharges": {"MonetaryValue": "$MonetaryValue}"}}}}
 
All, the correct way to format the output string for REST API output is below. Each JSON object needs separating using a period.

ShipmentResponse.Response.NegotiatedRateCharges.MonetaryValue
 
If all that you're doing is mapping a json to individual variables, you don't even have to use manipulate body. You get to "map" to the locations of the data you're after. The map in your json is thankfully simple! no square brackets which means we'd have to parse through (and might require a manipulate body script)

Here's what it would look like to map output from the API call. Capitalization and spelling important when you're "drilling" to the specific variable. And like I said, square brackets means you might have to get a little crazier :)

ShipmentResponse.Response.NegotiatedRateCharges.TotalCharge.MonetaryValue
1661528478376.png
 
moderation caught my post (and evidently yours). i wonder when we graduate past the moderation stage?
 
If all that you're doing is mapping a json to individual variables, you don't even have to use manipulate body. You get to "map" to the locations of the data you're after. The map in your json is thankfully simple! no square brackets which means we'd have to parse through (and might require a manipulate body script)

Here's what it would look like to map output from the API call. Capitalization and spelling important when you're "drilling" to the specific variable. And like I said, square brackets means you might have to get a little crazier :)

ShipmentResponse.Response.NegotiatedRateCharges.TotalCharge.MonetaryValue
Dave, thank you for your response. I now have the output working as desired with the exception of the errors, which you guessed, are enclosed by the dreaded []. All I need from the error message is "Missing or invalid label specification label stock size width." I haven't been able to dig my way down to it yet.

{

"statusCode": 400,
"error": "java.lang.Exception: External Generic Call Failed See Log For Details: 400 {\"response\":{\"errors\":[{\"code\":\"120705\",\"message\":\"Missing or invalid label specification label stock size width.\"}]}}"

}
 
Dave, thank you for your response. I now have the output working as desired with the exception of the errors, which you guessed, are enclosed by the dreaded []. All I need from the error message is "Missing or invalid label specification label stock size width." I haven't been able to dig my way down to it yet.

{

"statusCode": 400,
"error": "java.lang.Exception: External Generic Call Failed See Log For Details: 400 {\"response\":{\"errors\":[{\"code\":\"120705\",\"message\":\"Missing or invalid label specification label stock size width.\"}]}}"

}
OK so this one is deep! you get an "outer" json which you drill to just by specifying error on the left

that gives you a string where if you split it after the 400 (or read from the first occurance of "{", or or or... lots of options), you get an escaped json string that has within it an array of errors.

you're gonna need some scripting to work this one out, I hate to say, IF you really want to get down to just the message attribute within the errors array. If your error message might vary in any way, your script might fail. it's an interesting problem, and if you're not a scripter it might be worth hiring some consulting time after compiling every possible error message format that might pop back out!
 
Last edited:
Oh yes, and for future reference, here's an example of a json with square brackets, and how to reference the first element within square brackets. With the attached JSON, to get to the base_uri value and pass it on in an orchestration, you'd reference
accounts[0].base_uri

If you had an array of 2 accounts and wanted to get to the 2nd, you'd do accounts[1] and so on.

You can also in this example extract the accounts object and loop through it via Iterate Over. I like lazy mapping though.


Code:
{
    "sub": "asdf",
    "name": "dave",
    "given_name": "dave",
    "family_name": "Wagoner",
    "created": "2022-08-01T18:19:29.727",
    "email": "[email protected]",
    "accounts": [
        {
            "account_id": "dave",
            "is_default": true,
            "account_name": "DaveCorp",
            "base_uri": "https://demo.davecorp.net"
        }
    ]
}
 
Hi @Rhett,

It as say @DaveWagoner , you can iterate in the tree with dots and brackets. For example, I use a service rest to get exchange from Eur (ecb), it return:
1661862298416.png

So, I put in the output:
dataSets[0].series.0:0:0:0:0.observations.0[0] to get 0.9986
1661862387289.png
 
Dave, thank you for your response. I now have the output working as desired with the exception of the errors, which you guessed, are enclosed by the dreaded []. All I need from the error message is "Missing or invalid label specification label stock size width." I haven't been able to dig my way down to it yet.

{

"statusCode": 400,
"error": "java.lang.Exception: External Generic Call Failed See Log For Details: 400 {\"response\":{\"errors\":[{\"code\":\"120705\",\"message\":\"Missing or invalid label specification label stock size width.\"}]}}"

}
I just today found another object that includes "embedded" json - the composite page BLOB object! it has JSON within XML. fun stuff.
 
Back
Top