Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

HTTP client to get response from post call using javascript

Here is my code.

var SchCodeRequest = '{ "aa" : "","abb" : ""}';
var req = JSON.parse((JSON.stringify(SchCodeRequest)));
var url = "https://localHost";
var operation = "POST";
var headers = { 'Content-Type' : 'application/json' };
var request = new Request(url, operation, headers, req);
print(request);
var exchange = httpClient.send(request);
if (httpres.isSuccess()) 
{ 
  var resp = exchange.getResponse();
  print(resp);
  var hresp = JSON.parse(resp);
  context.setVariable("finalResponse", hresp);
  //var responsePayload = exchange.getResponse().content;
}
else 
{
  var resp = httpres.getError();
  context.setVariable("httpres", resp); 
}

when I try to hit the request it printing as below request:https://localHost? But the expected output should be like below https://localHost

0 6 2,452
6 REPLIES 6