How to get a single value using REST API?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-26-2016 12:03 PM
I want the sys_id from a single row from the user table using the REST API. I don't want to go through the effort of creating a java object, creating the object (Json -> java), then retrieving the value. Is there a way to query so that I only get the sys_id returned?
What I have thus far:
"https://myCompany.service-now.com/api/now/table/sys_user?user_name=" + username
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-26-2016 12:06 PM
If you are on the Geneva release, a scripted REST would allow you to do this:
You could pass in just the username and then you can control the response back too.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-26-2016 12:08 PM
We're still on Fuji unfortunately...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-26-2016 12:13 PM
Bummer, you could do it with SOAP in Fuji but Geneva introduces scripted REST.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-26-2016 04:38 PM
Have you thought about using sysparm_query to get the single record (based on employee ID or something) and then sysparm_fields to return just the sys_id? Something like this (only I queried on the name field)
https://yoursite.service-now.com/api/now/table/sys_user?sysparm_limit=10&sysparm_query=name=Abel Tuter&sysparm_fields=sys_id
The result was:
{
"result": [
{
"sys_id": "62826bf03710200044e0bfc8bcbe5df1"
}
]
}
Use the REST API explorer to craft your REST request. Links near the SEND button will give you code snippets for ServiceNow (JavaScript), cURL, Python, Ruby, etc.