
- 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:11 AM
I don't know the sys id of the data in the first place. Example: If i want to see if a user record is present in a target environment, i just have the email id of the user id with me...so naturally i will apply a query like sysparm_query=email=XYZ.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-24-2015 11:26 AM
Hi ravio,
Does my last reply fix the issue you are having?
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.