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

Set Multiple headers in Javascript httpclient

Not applicable

How do I set multiple headers in javascript httpclient request? I have the below code it doesnt set the values properly.

var headers = {'Content-Type':'application/json', 'Accept':'application/json', 'Cache-Control':'no-cache'};

var auditors = new Request();

auditors.url = "https://demo.api.confirmation.com/auditor";

auditors.headers = headers;

var auditor = httpClient.send(auditors);

context.setVariable("auditorsResponse",auditor.code);

I get the auditorsResponse as org.mozilla.javascript.Undefined@25ef85d5

0 5 16.6K
5 REPLIES 5