var r = httpClient.get("http://mocktarget.apigee.net/json");
// set the pending request into a context variable
context.setVariable('pendingResponse', r);
var r = context.getVariable('pendingResponse');
if (r) {
// retrieve the pending request from the context variable
r.waitForComplete();
if (r.isSuccess()) {
print(r.getResponse().headers['Content-Length']);
}
}
I am not sure how to retrieve all response headers names though. If you know the header, You can retrieve using above code. Hope it helps.
@Sabthar , Awesome, +1, Thank you for sharing the code & it works as expected. I have tried “r.getResponse().headers” without JSON.stringify. Just wondering, How did you came to know about above solution ?
@Anil Sagar, @Sabthar – Based on your code I created a new sample called iterate-headers in our api-platform-samples site on GitHub. I also linked to it from the Apigee docs you suggested above. – Will