How to access the HTTPCLIENT response data

I am having trouble reading the values on HTTP Request on Javascript file.

  var response = httpClient.get("http://mocktarget.apigee.net/json");
  var val = response.getResponse().content.asJSON;
  print(val);

The val on my log is printed with:

[object Object]

I tried JSON.parse the val, but it is not returning anything. I do not understand why I am not able to parse it.

Solved Solved
0 3 1,391
1 ACCEPTED SOLUTION

sujnana
Participant IV

Use JSON.stringify to print the data

var response = httpClient.get("http://mocktarget.apigee.net/json");
var val = response.getResponse().content.asJSON;
print(JSON.stringify(val));

View solution in original post

3 REPLIES 3

sujnana
Participant IV

Use JSON.stringify to print the data

var response = httpClient.get("http://mocktarget.apigee.net/json");
var val = response.getResponse().content.asJSON;
print(JSON.stringify(val));

Hi Sujnana, can you please provide the wayout to deal with XML response?

Please don't ask questions in comments to answers. You posted a toplevel question, and it has been answered.