- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-22-2016 09:24 PM
Good day raiders of the lost ark,
- I've created a Scripted REST API within a Scoped application (geneva developer instance).
- This API has 2 resources.
- Resource #1 calls Resource #2 and tries getCookies() with the response from #2.
- In the logs i can see : NullPointerException ==> 27: var cookies = res.getCookies();
and the response of Resource #1 is:
{
"error": {
"message": null,
"detail": null
},
"status": "failure"
}
Resource #1 Code:
(function process(/*RESTAPIRequest*/ request, /*RESTAPIResponse*/ response) {
var restMessage = new sn_ws.RESTMessageV2();
restMessage.setHttpMethod('get');
restMessage.setEndpoint('https://INSTANCE.service-now.com/api/x_82127_sApp/myApi/cookieMonster');
var resp = restMessage.execute();
var cookies = resp.getCookies();
var body = [];
for(var i=0;i<cookies.size();i++) {
body.push(cookies.get(i));
}
response.setBody(body);
})(request, response);
Resource #2 Code:
(function process(/*RESTAPIRequest*/ request, /*RESTAPIResponse*/ response) {
something = [
{"id": 12034, "worked":"yes"},
{"id": 1234, "worked":"yes"},
{"id": 12, "worked":"no"}
];
// implement resource here
response.setBody(something);
})(request, response);
I have tried this example in Global scope and it works perfectly.
Therefore I'm guessing it's something to do with being a Scoped Application. I checked the scoped api and under "RESTResponseV2", getCookies() is there.
I've checked in the REST API Explorer and Resource #2 works fine and returns 200, Resource #1 returns 500 internal.
I've checked the setEndPoint and it's the correct endpoint (copy and pasted).
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-11-2017 07:25 PM
For those who (if anyone) come across this issue, it's actually a problem and is currently being looked at by servicenow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-22-2016 10:35 PM
#sorryfordoublepost
getheaders() and getBody() are working as usual. Just seems to be something to do with getCookies().
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-23-2016 02:27 AM
setBasicAuth??
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-23-2016 02:49 PM
The two end points have basic authentication off. Thanks for input.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-11-2017 07:25 PM
For those who (if anyone) come across this issue, it's actually a problem and is currently being looked at by servicenow