Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

Manage REST Message response (getBody())

LdR
Tera Expert

I would need to derive, starting from the body of a response to a REST call {responseBody = response.getBody ();} the amount of rows, and extract single field arrays in order to populate a table.
I saw on the Documentation that the getBody () method returns a string, whose syntax, however, is like a JSON.

How can I solve?
Thank you ☺

1 REPLY 1

BrianD502676804
Kilo Sage

Hi Leo,

You are correct, I believe it is JSON.  Here is an example of how to use it from some of the OOB code to parse the response back into an object:

 

			var responseBody = response.getBody();
			
			var parser = new JSONParser();
			var parsed = parser.parse(responseBody);

 

This is from the (OOB) GoogleCaptcha script include.  Let us know if you have more questions.

 

Thanks,

-Brian