I tried
var resheader = context.getVariable("calloutResponse.header");
but i am not bale to see the headers which is coming from back end ,
Can anyone know how can we fetch the headers from callout response?
Thanks,
Ambili
Solved! Go to Solution.
Here is a JSC snippet that will print all the headers in the response:
var headerNames = context.getVariable("response.headers.names") + ""; headerNames.split(", ").sort().forEach(function(headerName) { if (headerName) print(headerName+":"+context.getVariable("response.header."+headerName)); });
Change the name of response.headers to whatever you named your callout response.
See similar post here.. Let us know if it helps you.
Here is a JSC snippet that will print all the headers in the response:
var headerNames = context.getVariable("response.headers.names") + ""; headerNames.split(", ").sort().forEach(function(headerName) { if (headerName) print(headerName+":"+context.getVariable("response.header."+headerName)); });
Change the name of response.headers to whatever you named your callout response.
Thanks David,
now I am able to see the Headers ,
but i need header + values
I tried
response.header.{header_name}.value
response.header
response.headers.values
response.headers.names.values
but nothing is working for me , Can you suggest some way to fetch header + values ?
context.getVariable("response.header."+headerName) bit from @David Allen's code gives you the value of the header.
E.g. if the header name is Content-Length, then this will give you the value:
var contentLengthValue = context.getVariable('response.header.Content-Length');