
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2015 11:27 AM
Hello all,
I am using the scriptable REST API to delete some data from a target SN environment
var r = new RESTMessageScripted("post", "https://"+instanceName+".service-now.com/sys_user_grmember.do");
r.addHeader("Content-Type", "application/json");
r.addRequestParameter("JSONv2", "true");
r.addRequestParameter("sysparm_query", 'sys_id='+id);
r.addRequestParameter("sysparm_action", "delete");
r.setBasicAuth(authenticatingUsername, authenticatingPassword);
response = r.execute();
This doesnt seem to work. The response code that i am getting is 200 so i dont think it is the authentication issue. What am i missing?
Solved! Go to Solution.
- Labels:
-
Integrations
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2015 11:35 AM
var request = new GlideHTTPRequest ('https://myinstance/api/now/table/incident/0fbbeddad47e1100a92e188eafa1dd60');
request.setBasicAuth("admin","admin");
request.addHeader('Accept','application/json');
request.addHeader('Content-Type','application/json');
var response = request.del();
gs.log(response.getStatusCode());
gs.log(response.getBody());
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2015 11:45 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2015 07:27 AM
Hi Mike,
This is a good thing to know. I want to quit using 'RESTMessageScripted' and use this out of the box 'GlideHTTPRequest'.
With GlideHTTPRequest, i can delete, update and insert data.
However there is this one use case where i want to fetch some data by querying it. In the documentation i did not find anything for that.
Here is the code what i use today
var r = new RESTMessageScripted("post", "https://"+instanceName+".service-now.com/sys_user_grmember.do");
r.addHeader("Content-Type", "application/json");
r.addRequestParameter("JSONv2", "true");
r.addRequestParameter("sysparm_query", 'group='+group+'^user='+user);
r.setBasicAuth(authenticatingUsername, authenticatingPassword);
response = r.execute();
var jsonData = new JSON().decode(response.getBody().toString());
if(jsonData.records.length == 0){
return true;
} else {
return false;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2015 11:46 AM
Hi Ravish,
Yes that is the REST API to handle tables and that's why name is Table API