How to fetch table records through rest api?

mehak1890
Tera Expert

Dear All,

I'm not able to fetch all table records from one table. For e.g i tried below queries.

https://instance.service-now.com/api/now/table/cmdb_ci_win_server?sysparm_limit=100

For above query m getting records but i want to fetch all records so tried -1 or blank but getting error page.

https://instance.service-now.com/api/now/table/cmdb_ci_win_server?sysparm_limit=-1 

throwing error "Invalid value given for sysparm_limit"

https://instance.service-now.com/api/now/table/cmdb_ci_win_server

throwing error as well. "Opening and ending tag mismatch:"

 

Could anyone pls help how to fecth all records from one table? Thansk, Mehak.

 

 

6 REPLIES 6

Ron Legters
ServiceNow Employee
ServiceNow Employee

What interface are you using? I just typed your URL where you got the tag mismatch into the address bar in Chrome and it returned all the Windows Server records in my instance. I'm wondering if maybe the tool you're using is appending something to the URL you can't see.

mehak1890
Tera Expert

Hi Ron/ All,

I also tried below scenarios but still not able to understand what is the root cause, why m not getting any response on below query.

https://instance.service-now.com/api/now/table/cmdb_ci_win_server

When I'm trying for cmdb_ci_linux_server table, then its working fine. but not for win table.

find_real_file.png

 

But for this URL I'm getting below error. "Error on Line53 at column number"

https://instance.service-now.com/api/now/table/cmdb_ci_win_server

find_real_file.png

When I'm trying the order by DESC query then I'm getting below error. "Error on Line69 at column number"

https://instance.service-now.com/api/now/table/cmdb_ci_win_server?sysparm_query=ORDERBYDESCname

find_real_file.png

 

When I'm trying the order by query then I'm getting below error. "Error on Line 53 at column number"

find_real_file.png

 

As per my understanding its look likes data issue in 'cmdb_ci_win_server' table but I'm not 100% sure, if data issue but how i can fix it? or any other issues?

Also When I'm trying below query with fields I'm getting response. In this table there are total 123 fields, and i tried with all attributes and getting response.

https://instance.service-now.com/api/now/table/cmdb_ci_win_server?sysparm_fields=name%2Cu_active%2Cshort_description%2Cserial_number%2Clocation%2Cu_ci_comments

 

Could anyone pls help? how to resolve this issue?

 

Thanks,

Mehak

 

where exactly are you testing it ?

did you try on rest api explorer and is it giving you the correct count ?

No Harsh, I'm testing on browser.