
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-23-2015 10:54 AM
Hello,
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 using john andersens RESTMessageScripted. I want to use GlideHTTPRequest instead of RESTMessageScripted.
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;
}
Edit: As shown in Line 4 of the script, i am applying a specific query. I want to do the same with GlideHTTPRequest so that i do not fetch all the data. Can i apply a specific query using GlideHTTPRequest?
Solved! Go to Solution.
- Labels:
-
Integrations
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-24-2015 11:10 AM
Better yet, use %5E instead of ^ and it will work.
You can also use request.addParameter('sysparm_query', 'active=true%5Enumber=xxxxxxx') to set the query.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-24-2015 11:10 AM
Better yet, use %5E instead of ^ and it will work.
You can also use request.addParameter('sysparm_query', 'active=true%5Enumber=xxxxxxx') to set the query.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-24-2015 01:12 PM
This is what i used and it worked. Thanks.
var request = new GlideHTTPRequest('https://XXXXXXXXXXXX.service-now.com/api/now/table/incident');
request.setBasicAuth("XXXXXXXXXXXX", "XXXXXXXXXXXX");
request.addHeader('Accept', 'application/json');
request.addParameter('sysparm_query','active=true%5Enumber=XXXXXXXXXXXX');
var response = request.get();
var jsonData = new JSON().decode(response.getBody().toString());
gs.log(response.getStatusCode());
gs.log(response.getBody());
gs.log(jsonData.result[0].number);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-24-2015 09:13 AM
Hey Ravio,
Why do you want to use GlideHTTPRequest instead of RESTMessageScripted?
Thanks,
Bryan

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-24-2015 10:29 AM
It is a 3rd party script and won't be supported by ServiceNow if things don't work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-24-2015 10:53 AM
Retrieving a specific record from the table can be done with the following url syntax
GET https://devxxx.service-now.com/api/now/table/{tableName}/{sys_id}
So you wouldn't need to specify the number in the sysparm query.