Fetching Open and Pending state tickets using rest api

Balakrishnan N
Kilo Contributor

Hi Team,

I have a requirement to fetch all Open and Pending state tickets on single api call.  I have an idea how to fetch both states on separate rest api call

for example to fetch open ticket we can the below mentioned url

"https://instance.service-now.com/api/now/v1/table/incident?state=1"

and for Pending state we can use the below url

"https://servionindev.service-now.com/api/now/v1/table/incident?state=-5"

So my concern is need to fetch both the states on single api call.  Kindly help me get out this issue.

 

Regards,

Bala N

1 ACCEPTED SOLUTION

Danny Sun
Tera Guru

Hi,

I think you can try this: https://instance.service-now.com/api/now/table/sc_task?sysparm_query=state=1^ORstate=-5.

Regards,

Danny

View solution in original post

8 REPLIES 8

Danny Sun
Tera Guru

Hi,

I think you can try this: https://instance.service-now.com/api/now/table/sc_task?sysparm_query=state=1^ORstate=-5.

Regards,

Danny

Balakrishnan N
Kilo Contributor

Thanks Danny.  your suggestion is helped me to achieve my goal.

Danny Sun
Tera Guru

NP

Himanshu Dubey
Giga Guru

Hi 

You can build your REST Query more easily by going to System Web Services > REST > REST API Explorer

find_real_file.png

and end your end point with condition state is open or pending look like 

https://dev93456.service-now.com/api/now/table/sc_task?sysparm_query=state%3D1%5EORstate%3D-5&sysparm_fields=number%2Cstate&sysparm_limit=1

Mark Correct if my answer solves your issue and also mark 👍 Helpful if you find my response worthy.

Thanks & Regards

Himanshu Dubey