Is it possible to write a REST Response Header to the Workflow Scratchpad?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-17-2015 09:18 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-17-2015 10:16 AM
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();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-17-2015 11:16 AM
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-21-2015 01:19 PM
Do you know if it's possible to do this with the workflow REST utility?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-24-2018 12:50 PM
Thanks Srinivas. Exactly what am looking for.