JsonParserOperation failed: The transformer returned null as output

Ravi Srikanth1
Tera Contributor

I created a custom Flow Action which calls a REST Endpoint and I am parsing the response from REST call using the JSON Parser step. 

 

JSON Parser step works fine whenever I get response in payload, however in some valid cases when there is no data to send the third party application returns empty response in the payload and in such cases JSON parser step is failing with "JsonParserOperation failed: The transformer returned null as output"  error.

 

How can we handle the JSON parser step not to error when the response is empty ?

 

RaviSrikanth1_0-1702456738354.png

 

I already tried configuring the "If this step fails": Don't stop the action and go to the next step. but this JSON parser step still fails.

 

Thanks

4 REPLIES 4

Ankur Bawiskar
Tera Patron
Tera Patron

@Ravi Srikanth1 

in that custom action you can ensure parsing is done when the response is not empty

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Ravi Srikanth1
Tera Contributor

Hi @Ankur Bawiskar 

 

How can we stop the execution in the previous step, if the response is empty ? I don't think we can skip execution of any step like JSON Parser within the action.

 

I want the action to complete as success with empty output, since there is no response from REST call.

 

Thank You,

Community Alums
Not applicable

Anyone figured this one out? I have the same issue

CDoernbrack
Tera Contributor

We have solved for this issue by creating a script action prior to the JSON parser. 

 

CDoernbrack_0-1740583004313.png

The script will check to see if the response body is empty and if so throw an error such that we don't go to step 3, the JSON Parser.

 

CDoernbrack_2-1740583056631.png

 

 Then in the Evaluation we handle the error. Here we check to see if the error came from step 2. 

CDoernbrack_3-1740583300581.png

 

Note it is set as "Don't treat as error" because we don't want the flow that is using the action to error out because the step in the action is treated as an error. We want to send the action status code of 100 back to the main flow and allow it to proceed accordingly. Ex, if status code is 100 then do X. In our case we were querying membership and if there are no members returned by the API call then of course you get an empty response body. This isn't an error, it simply means the main flow needs to branch in a different direction. Therefore, we check for action status code == 100 and proceed accordingly.