How to get only the support groups from 'cmdb_ci_service' table through REST API?
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi All,
I want to get only the support groups from 'cmdb_ci_service' table through REST API.
Getting response as :
I am getting multiple records with same Support group name, but I want to display only unique values.
How can we achieve this?
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago - last edited 3 weeks ago
Hi @User205031 ,
- The standard Table API (which you are currently using) returns individual records. It does not natively support "DISTINCT" or "Unique" operations to filter out duplicates on the server side.
- To achieve this without writing a custom script, you should use the Stats (Aggregate) API. This API is designed specifically to group records and return unique values.
- Here is how to configure your request to get unique Support Groups:
Solution: Use the Stats API
Change your endpoint from /table/ to /stats/ and use the sysparm_group_by parameter.
1. The Request URL Change your URL structure to: GET https://instance.service-now.com/api/now/stats/cmdb_ci_service
2. The Parameters In your REST API Explorer (or your code), configure the parameters as follows:
- sysparm_query: support_group.nameSTARTSWITHNetwork (Keep your existing filter)
- sysparm_group_by: support_group.name (This is the magic parameter that groups duplicates into a single entry)
- sysparm_count: true (This tells the system to just return the groupings)
Regards,
Vishal