Error getting data from GET request

I tried sending a get request to an API which returns a JSON format that I need to read from the endpoint.
An example of the response is:

“data”: [
" room charges",

I’ve created this script in Groovy and it definitely works because it’s not using the fallback answer output.
However, the only result I ever get back is “false” and verification with Postman shows the API endpoint is functioning. I’m not exactly sure what is the error here. Image of the Groovy script I’ve wrote is attached below!

It looks like you have specified an output field data, which implicitly defines ‘data’ as a variable available in the script node. But inside the script you define data as a local variable def data = "". So I think if you remove line 2 from your script it will work.

Hi Lucas,

It was false before I defined data as an inner variable! Not sure where else I went wrong with this!

Did you manage to get it to work in the end? If not, perhaps you can add a few println statements, one that prints the value of ‘data’ (inside the try) and another that prints the exception (inside the catch), should it occur. You should be able to see the results in the ‘Engine: Online’ tab in tryout.