- 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
08-01-2017 02:06 PM
Does anyone know if this has been resolved and in what version?
I see this same issue on Istanbul Patch 7
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2017 03:33 PM
It looks like it's still an issue in Jakarta!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2018 11:52 AM
How many years will ServiceNow take to fix it?
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2018 04:31 PM
Hello,
I need to create a Webservice API where input is: Sys ID of any record and output is: all *related* active records to that sys id. The relationships between the tables is maintained in Relationships under system definition.
Could you please guide me how to implement this? Sample code would be great.
Input: Sys ID of the record
Output: All *RELATED* active records from *VARIOUS* tables (in the following JSON format):
{
"result": [
{
"Sys ID": "5520267",
"CI Name": "Record 1",
"Table Name": "u_table_a"
},
{
"Sys ID": "5520367",
"CI Name": "Record 2",
"Table Name": "u_table_a"
},
{
"Sys ID": "8331210",
"CI Name": "Record 1",
"Table Name": "u_table_b"
},
{
"Sys ID": "8321210",
"CI Name": "Record 2",
"Table Name": "u_table_b"
},
{
"Sys ID": "3042006",
"CI Name": "Record 3",
"Table Name": "u_table_b"
},
{
"Sys ID": "4509847",
"CI Name": "Record 1",
"Table Name": ""u_table_c"
}
{
"Sys ID": "4509247",
"CI Name": "Record 2",
"Table Name": ""u_table_c"
}
]
}