Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

JSON Parser Step Issue

Richard Hine
Tera Guru

Hi,

Relatively new to working with Flow Designer as previously I had hand crafted integrations in script includes but my current customer wants to use IH.

I have a REST call which is receiving a simple JSON message containing the Transaction ID as a response.

{
"Transaction ID":"44081c08-453a-11e6-a9de-d99213c464e0"
}

I have this set up with the JSON Parser step and generated the target:-

find_real_file.png

No matter what I do, the parser step fails with "JsonParserOperation failed: The transformer returned null as output"

If I remove the space in 'Transaction ID' in the sample payload to make 'TransactionID' and regenerate the target, it works as expected, but this is a software vendor supplied API so I cannot remove this space when working with live systems.

The issue must be related to the space in the Name field on the target structure but I cannot find a way to work around it.

Has anyone encountered this issue and resolved it? Other message structures from the same vendor are more complex, so ideally I want to decide if it is effective to use the JSON parser step at all.

Any help greatly appreciated,

Richard

1 ACCEPTED SOLUTION

Richard Hine
Tera Guru

The issue looks to have been the JSON parser step in FD. I removed it and replaced it with a script step and all working fine.

(function execute(inputs, outputs) {

  	if(!gs.nil(inputs.response_body)){
        // Parse the JSON body.
        var responseObj = JSON.parse(inputs.response_body);        
        outputs.transactionid = responseObj["Transaction ID"];
    }
})(inputs, outputs);

Thank you for your help.

Richard

View solution in original post

7 REPLIES 7

Richard Hine
Tera Guru

The issue looks to have been the JSON parser step in FD. I removed it and replaced it with a script step and all working fine.

(function execute(inputs, outputs) {

  	if(!gs.nil(inputs.response_body)){
        // Parse the JSON body.
        var responseObj = JSON.parse(inputs.response_body);        
        outputs.transactionid = responseObj["Transaction ID"];
    }
})(inputs, outputs);

Thank you for your help.

Richard

Hi,

Yes, as I had mentioned above, the JSON parser step must not be able to use square bracket notation and a script step was recommended.

Glad it's resolved.

If my reply above helped guide you Correct, please mark as Correct.

Thanks and take care! 🙂


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

Hi @Richard Hine 

I see you marked your own reply as Correct.

I'm glad your issue is resolved. To clarify, I did mention both the script step and how to utilize the square bracket notation in my replies above.

If I helped guide you Correctly, it's requested to please mark the relevant reply as Correct.

Thanks and take care! 🙂


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!