How can I use the callback function, utilizing method ‘send’, ??, because using only ‘get’ I can’t send any headers.
var exchange = httpClient.send(myRequest);
exchange.waitForComplete();
How can I use the callback function, utilizing method ‘send’, ??, because using only ‘get’ I can’t send any headers.
var exchange = httpClient.send(myRequest);
exchange.waitForComplete();
Should be the same as when using httpClient.get. See example here: https://docs.apigee.com/api-platform/antipatterns/wait-for-complete
Here’s some sample code:
var headers = {'X-SOME-HEADER' : 'some value' };
var myRequest = new Request("https://example.com", "GET", headers);
httpClient.send(myRequest, function(res, err) {
if (res) {
print('content: ', res.content);
} else {
print('err: ', res.err);
}
});
or
var headers = {'X-SOME-HEADER' : 'some value' };
var myRequest = new Request("https://example.com", "GET", headers);
function onComplete(res, err) {
if (res) {
print('content: ', res.content);
} else {
print('err: ', res.err);
}
}
httpClient.send(myRequest, onComplete);
yup! That’s the way to do it. If this isn’t clear from the official documentation, please send feedback to the docs team via the documentation page .