Is it possible to write a REST Response Header to the Workflow Scratchpad?

jakelaux
Kilo Explorer

Hello all,

An integration I'm working on requires me to grab information from a REST response header. I've been able to write sensor scripts to parse the REST body with various other REST messages, however, I am having a heck of a time trying to get the REST response headers.

Is there a way that I could grab the response header and write it to the scratchpad? Or is there any other way I could get the data out of the header that I need?

I've tried getHeaders() but I don't know if I was using it correctly for there is no signature or usage examples on the wiki site:

http://wiki.servicenow.com/index.php?title=RESTResponseV2_API#gsc.tab=0

Thanks,

Jacob Laux

5 REPLIES 5

srinivasthelu
Tera Guru

Hi Jacob,



I just tried, It worked like a charm with the below example. I am able to print all headers in the background. Let me know if anything specific if you are looking for.





try {


var r = new sn_ws.RESTMessageV2('test', 'get');


var response = r.execute();


var responseBody = response.getBody();


var httpStatus = response.getStatusCode();


var headers=response.getHeaders();




for(var i in headers){


gs.print(i+'value'+headers[i])


}




}


catch(ex) {


var message = ex.getMessage();


}


Is there a way I can do this with using the REST Message Utility in the workflow itself? And would it be possible to write this to the scratchpad instead of the script log?


Do you know if it's possible to do this with the workflow REST utility?


Thanks Srinivas. Exactly what am looking for.