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, 

 

Could you want to make it like this "https://instance.service-now.com/api/now/v1/table/incident?state=1^ORstate=-5"?

 

Regards,

Danny

Balakrishnan N
Kilo Contributor
Thanks Danny yes I want something like that... let me try with this whether I get the response from both the states... Seems more helpful to me.....

Balakrishnan N
Kilo Contributor

Hi Denny,

 

I have tried with your approach but couldn't bring any record either Open or Pending state and I am getting error response like

{
    "error": {
        "message": "No Record found",
        "detail": "Records matching query not found. Check query parameter or offset parameter"
    },
    "status": "failure"
}
 
and my url is 
https://instance.service-now.com/api/now/v1/table/task?sys_class_name=sc_task&state=1^ORstate=-5
 
 
on the whole which didn't help me to resolve this issue.  If you any other idea pls help me with this.

Balakrishnan N
Kilo Contributor

Team,

 

I've tried like this below as well but this returns all records means didn't consider my state condiiton.

https://instance.service-now.com/api/now/v1/table/task?sys_class_name=sc_task&state in (1,-5)