E9.2 Cannot parse connector output

nadeem69

Member
New to Orchestrator/API calls.

I have a connector that retrieves an access token from an API. When I press test I can see the output json but somehow I can't assign the token to an output variable.
1.png
in debugger it shows null as out put:
{
"data.access_token": null
}
Please help.
 
Looking at your signature, something tells me you're not B7333 any more :D

Try dropping data. and just leave it access_token. I think I ran into something like this before and had to fool around with it until it worked, and I think this was it. Sorry if it's not!
 
Thank you Dave, no, I am not anymore on B7333 :D
I was actually trying with access_token only and it didn’t work. I saw in another post where you recommended to use full path with period in between, but it didn’t work either. Can a jruby script solve it? If yes How?
 
I'll tell you, these days I prefer to parse out API calls in a script. There's often some sort of transformation or other operation I need to do rather than just pull out a variable, and I want my step to be visible rather than part of the API call. It's a personal preference -- you'll see others say to just manipulate output within the connector.

But in your case you just want a simple variable! It should work! I don't' see any sort of array in the response that would call for a change of your value format either.

If I were standing over your shoulder and we were working through this, I'm sure we'd figure it out by trial and error. It's much harder trying to suggest things from this far away!

Here's what I'd do if I needed to do more complex things against that API call: I'd set the API call connector to "return raw data" in the transformation screen. I'd use DEBUG to get the actual full response from the API. I'd plug that response into ChatGPT and tell it that I need to extract the token variable. Then I'd plug chatGPT's script into Orchestrator's scripting template, with 1 input - responseJSON, and 1 output - tokenVar. Then hook up all the plumbing there and move along, since the scripting method removes any guesswork.
 
Thanks Dave,
I tried it but I get no raw data in response. Only 'Test' button shows that above JSON. I don't get any error on executing this API call.
 
Thanks Dave,

Finally it works by using this jruby script:

require 'json'
require 'rexml/document'
include REXML
def main(orchAttr, inputMap)
jsonIn = JSON.parse(inputMap)
rowset = jsonIn["data"]["access_token"]
outJSON = {}

outJSON["access_token"] = rowset

jsonOut = JSON.generate(outJSON)

return jsonOut
end
 
Back
Top