Filtering incidents by tags via API

tum4ik
Kilo Explorer

Hello!

I want to get incidents by using, for example table API, and then filter them by tags.

For example I've assigned these two tags: "Tum4ik" and "ffff"

find_real_file.png

But in some reason I don't see these tags in the response for https://service-now-instance.com/api/now/table/incident

There is property "sys_tags", but it is always empty.

Response JSON:

{

                      ....................

                      "reopen_count": "",

                      "sys_tags": "",

                      "escalation": "0",

                      "upon_approval": "proceed",

                      "correlation_id": "",

                      "location": "",

                      "category": ""

}

Could somebody help me? Is there some API to get items filtered by tags?

1 ACCEPTED SOLUTION

First, I went to the list and built the filter I wanted. Example: incidents tagged with Android, look like this:



find_real_file.png


Then, I right click on the breadcrumbs of the filter to get the query.



find_real_file.png



Then I pasted that in to the sysparm_query field in the REST API Explorer to test...



find_real_file.png



Then I checked the URL after hitting Send and it shows me what I need to build for the API.



find_real_file.png


View solution in original post

7 REPLIES 7

Lakshmaiah Dump
Giga Expert

Hi,



Following article might be helpful to you.



Re: Difference between u_tags and sys_tags



I feel that you might be required a scripted rest api or you need to directly filter based tag name, As I shown in below example.



GET https://dev37568.service-now.com/api/now/table/incident?sysparm_limit=1&sys_tags.46da4b68db5c1300773...



Hit ✅Correct, ��Helpful, or ��Like, Endorsers depending on the impact of the response


@Lakshmaiah Dumpala


First, I went to the list and built the filter I wanted. Example: incidents tagged with Android, look like this:



find_real_file.png


Then, I right click on the breadcrumbs of the filter to get the query.



find_real_file.png



Then I pasted that in to the sysparm_query field in the REST API Explorer to test...



find_real_file.png



Then I checked the URL after hitting Send and it shows me what I need to build for the API.



find_real_file.png


ok, thanks. Those strings is the sys_id of tag. So now I know how to use it to build by API.