- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-26-2017 01:38 PM
I'm trying to use the ServiceNow API to get the system id for a particular support group. I would like to pass in the support group's name, like "Service Desk" and have the API return the support group's system ID.
Is this possible?
Solved! Go to Solution.
- Labels:
-
Integrations
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-26-2017 01:48 PM
Here is how you would do it with javascript
var requestBody = "";
var client=new XMLHttpRequest();
client.open("get","https://YOUR_INSTANCE.service-now.com/api/now/table/sys_user_group?sysparm_query=name%3DService%20Desk&sysparm_fields=sys_id&sysparm_limit=1");
client.setRequestHeader('Accept','application/json');
client.setRequestHeader('Content-Type','application/json');
//Eg. UserName="admin", Password="admin" for this code sample.
client.setRequestHeader('Authorization', 'Basic '+btoa('admin'+':'+'admin'));
client.onreadystatechange = function() {
if(this.readyState = this.DONE) {
document.getElementById("response").innerHTML=this.status + this.response;
}
};
client.send(requestBody);
Let me know if you need it in Python cURL, Perl, Ruby or Powershell instead.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-26-2017 01:42 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-26-2017 01:48 PM
Here is how you would do it with javascript
var requestBody = "";
var client=new XMLHttpRequest();
client.open("get","https://YOUR_INSTANCE.service-now.com/api/now/table/sys_user_group?sysparm_query=name%3DService%20Desk&sysparm_fields=sys_id&sysparm_limit=1");
client.setRequestHeader('Accept','application/json');
client.setRequestHeader('Content-Type','application/json');
//Eg. UserName="admin", Password="admin" for this code sample.
client.setRequestHeader('Authorization', 'Basic '+btoa('admin'+':'+'admin'));
client.onreadystatechange = function() {
if(this.readyState = this.DONE) {
document.getElementById("response").innerHTML=this.status + this.response;
}
};
client.send(requestBody);
Let me know if you need it in Python cURL, Perl, Ruby or Powershell instead.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-26-2017 01:55 PM
Thanks, this is perfect.