Capturing a value from a REST Response Body in Flow Designer

Chad R
Tera Expert

Hi All,

 

Another good one, I'm working on a REST API Bridge of sorts via flow designer and I have created a custom action with some script steps and REST step that accomplishes this. The script step is where I have an issue that I'm trying to parse out the response body and get the record number that was just created in instance b from instance a. First lets start with the response body: 

 

{"result":{"body":{"message":"Creation Success!","detail":"CNDT-INC2201988"}}}

 

The part I want is in the detail section the record number CNDT-INC2201988 here is what I have scripted so far in the script step on the action but its not returning a value:

 

Screenshot 2023-11-20 at 7.43.59 PM.png

 

Screenshot 2023-11-20 at 7.44.19 PM.png

 

The responseObject segment is where I'm fuzzy on exactly how to write that line, I haven't been able to find much on it either. Any help anyone can provide would be much appreciated!

1 ACCEPTED SOLUTION

AnveshKumar M
Tera Sage
Tera Sage

Hi @Chad R 

As per your response body JSON structure ({"result":{"body":{"message":"Creation Success!","detail":"CNDT-INC2201988"}}}),  In your script change line number 7 to this.

 

outputs.ensono_id = responseObject.result.body.detail;

 

If this didn't work, log the response body using gs.info() and give the structure.

gs.info("Response Body: " + JSON.stringify(responseObject));

 

Please mark my answer helpful and accept as a solution if it helped 👍✔️

 

Thanks,
Anvesh

View solution in original post

4 REPLIES 4

AnveshKumar M
Tera Sage
Tera Sage

Hi @Chad R 

As per your response body JSON structure ({"result":{"body":{"message":"Creation Success!","detail":"CNDT-INC2201988"}}}),  In your script change line number 7 to this.

 

outputs.ensono_id = responseObject.result.body.detail;

 

If this didn't work, log the response body using gs.info() and give the structure.

gs.info("Response Body: " + JSON.stringify(responseObject));

 

Please mark my answer helpful and accept as a solution if it helped 👍✔️

 

Thanks,
Anvesh

@AnveshKumar M ,

I'm on similar situation.

Creating a custom action & trying to retrieve u_partner_ticket_id from the response body.

 

I have tried both,  But no luck.

outputs.correlation_id = responseBody.result.u_partner_ticket_id;
outputs.correlation_id = responseBody.result.body.u_partner_ticket_id;

Naveen87_1-1714024984277.png

 

 

Naveen87_2-1714025012811.pngNaveen87_3-1714025023250.png

 

Naveen87_0-1714024968349.png

 

 

Also on incident, Description is not fetching group name.

Not sure why it says '[object GlideRecord] '.

Please suggest

Naveen87_4-1714025123637.png

 

 

 

Chad R
Tera Expert

Sorry I am late to responding this was super helpful and got this working thanks again!

I'm glad that it helped you 👍

Thanks,
Anvesh