Distinct on REST API Results
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-29-2020 12:03 PM
I am using the native REST API Explorer to fetch a list of users who have a specific role granted to them by being a group member. In the sys_user_has_role table a user could appear multiple times if they have multiple groups which duplicates the role in question. Short of changing roles in groups, is there a way to have the API response show only a distinct list of records?
- Labels:
-
Integrations

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-04-2020 01:24 PM
Hi Thomas,
Your user records have a "roles" field so rather than querying the sys_user_has_role table, you can query the sys_user table directly such as:
GET https://dev52040.service-now.com/api/now/table/sys_user?sysparm_query=roles%3Ditil&sysparm_fields=user_name%2Cname&sysparm_limit=10