Announcements
This site is in read only until July 22 as we migrate to a new platform; refer to this community post for more details.
Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

HTTPClient in Javascript not working? I use HTTPClient in Javascript to make a service callout, but i didn't get a response

Not applicable

Please find the code snippet that i used for making service callout in javascript:

var headers = {'Accept' : 'application/json'};

var request = new Request("targetURL", "GET", headers, "");

var exchange = httpClient.send(request), response, status;

exchange.waitForComplete();

print("exchange.getResponse.status:" + exchange.getResponse().status);

Response:

{ "fault": { "faultstring": "Execution of responseMapping failed with error: Javascript runtime error: \"TypeError: Cannot read property \"status\" from undefined (Test_js#7). at line 7 \"", "detail": { "errorcode": "steps.javascript.ScriptExecutionFailed" } } }

Request is received in target endpoint and it returns a success response. But response from target is not readable in javascript callout. Have anyone ever faced this issue. Kindly help.

2 6 8,310
6 REPLIES 6