The CreatorCon Call for Content is officially open! Get started here.

How to query servicenow tickets using its API (powershell)

Matt Campbell1
Kilo Contributor

Hello, I'm playing around with the SNOW API. 

I'm trying to figure a method to query for task numbers from this table sc_task.

Hoping to get some help with this.

Currently on Jakarta for SNOW

$uri = "https://xxxxxxx.service-now.com/api/now/table/sc_task? 

This my URL i'm using but i'm not sure what to add at the end of this URI to query a specific task number.

 

Thanks,

Matt

 

1 ACCEPTED SOLUTION

Ok..Do thhis

 

https://xxxxxxx.service-now.com/api/now/table/sc_task?sysparm_query=number=<Task Number>

 

The task number should be in format TASK0001231

 

For ex, I used

 

https://xxxxxxx.service-now.com/api/now/table/sc_task?sysparm_query=number=TASK0000001


Please mark this response as correct or helpful if it assisted you with your question.

View solution in original post

9 REPLIES 9

Getting further, seems our proxy is blocking something causing the output to be wonky. 

 

But i'll play around with it more. 

 

 

Having %D seems to come back with a null results. 

I tried running like this

https://xxxxxxx.service-now.com/service-now.com/api/now/table/sc_task?sysparm_query=number'0065475'"

 

but it was querying massive amounts of data(I stopped it), I think it was getting all the tickets within our SNOW system. 

Guessing I did something wrong.  Maybe this type of query isn't available in Jakarta ?

Ok..Do thhis

 

https://xxxxxxx.service-now.com/api/now/table/sc_task?sysparm_query=number=<Task Number>

 

The task number should be in format TASK0001231

 

For ex, I used

 

https://xxxxxxx.service-now.com/api/now/table/sc_task?sysparm_query=number=TASK0000001


Please mark this response as correct or helpful if it assisted you with your question.

Genius! I had single quotes around the task which broke it. 

 

Thanks for the help! I may have more question but i'll create a new thread for that.

 

sachin_namjoshi
Kilo Patron
Kilo Patron

You can always use OOB REST API explorer which is inbuild and provides code examples for powershell too.

 

find_real_file.png