Get a list of catalog/service names from ServiceNow

neha_joshi
Kilo Contributor

I am using the below REST API URL to get the list of Service names from ServiceNow. But this is returning non-service entries as well. Am I using the wrong URL? Please help.

https://<baseurl>.service-now.com/api/now/table/sc_cat_item?sysparm_fields=name,sys_id

1 ACCEPTED SOLUTION

Hi Neha,



You're close. To add the additional parameters on the URL, add &sysparm_query=sys_class_name!=sc_cat_item_guide&type!=package&sys_class_name!=sc_cat_item_content



I recommend using the REST API Explorer on your instance to help you build the URL and see the returned results. It's a great helper tool.


View solution in original post

10 REPLIES 10

The Services are the catalog items that are requestable. Below are the examples of some example Services


- Electronic Fax Services


- Decommission an existing Service


- Create Incident


etc



Some non-services that are showing up in this REST API are below -   https://<baseurl>.service-now.com/api/now/table/sc_cat_item?sysparm_fields=name,sys_id


- List Layout


- Getting Started


- Views


- Chart Colors


- Change Request Assignment


etc



I feel the URL that I am using to get the list of requestable items is wrong, and I may need to add more filters to it. The items showing under "Maintain Items" list is a subset of sc_cat_item table. I am interested in pulling the list that shows up under "Maintain Items". When I do View Source (in IE browser) on Maintain Items page, I see the below code.




// create the GlideList2 object for this list


var list = new GlideList2('sc_cat_item', 'sc_cat_item', '^type!=bundle^sys_class_name!=sc_cat_item_guide^type!=package^sys_class_name!=sc_cat_item_content);



When I tried adding the same above filters to the URL as shown below, I still get everything that are not needed.


https://<baseurl>.service-now.com/api/now/table/sc_cat_item?sysparm_fields=name,sys_id&sys_class_nam...


Hi Neha,



You're close. To add the additional parameters on the URL, add &sysparm_query=sys_class_name!=sc_cat_item_guide&type!=package&sys_class_name!=sc_cat_item_content



I recommend using the REST API Explorer on your instance to help you build the URL and see the returned results. It's a great helper tool.


Thank you so much! That was it. I was missing the "sysparm_query". The corrected URL looks like below.




https://<baseurl>.service-now.com/api/now/table/sc_cat_item?sysparm_fields=name,sys_id&sysparm_query...




spartacus1
Tera Contributor

Hi Everyone,



I'm wondering if somebody can help me too on my issue, currently I have a default 'filter' indicate below and it's working ... see below



sys_class_name!=sc_cat_item_content^active=true^sys_class_name!=sc_cat_item_guide^EQ



But, I want to add from to filter only category='Laptops', when i try it doesnt work ... see below



sys_class_name!=sc_cat_item_content^active=true^Category=Laptops^sys_class_name!=sc_cat_item_guide^EQ



Anybody? Thank you in advance


Try this instead:



sys_class_name!=sc_cat_item_content^active=true^category=Laptops^sys_class_name!=sc_cat_item_guide^EQ



Double check the value of your category list. You may need to use laptops instead of Laptops. I'm not sure since I don't know your choice list values.


FWIW, The best way to build these encoded queries is to use the list filter and then copy the query.


Using Filters and Breadcrumbs - ServiceNow Wiki