sysparm_query with REST Table API

Naveen Bagula
Tera Contributor

Topic: sysparm_query with REST Table API.

When we try to create an incident with below API, it should create a ticket with windows server CI, If there is no windows server CI in the system then it should create a ticket without windows server CI. – This is working fine

Good scenario: Assume “xyz007” is a windows server CI.

HTTP Method / URI

POST https://xxxxxx.service-now.com/api/now/table/incident?sysparm_query=cmdb_ci.sys_class_name%3Dcmdb_ci_win_server

Note: sysparm_query is “cmdb_ci.sys_class_name=cmdb_ci_win_server” in above URL

{"short_description":"SNOW admin testing","description":"Test case","cmdb_ci":"xyz007"}

 

Issue scenario: Assume “xyz007” is a database CI.

HTTP Method / URI

POST https://xxxxxx.service-now.com/api/now/table/incident?sysparm_query=cmdb_ci.sys_class_name%3Dcmdb_ci_win_server

Note: sysparm_query is “cmdb_ci.sys_class_name=cmdb_ci_win_server” in above URL

{"short_description":"SNOW admin testing","description":"Test case","cmdb_ci":"xyz007"}

In this case incident should be created without CI, however, the system is accepting a database CI and created a ticket. Can you please help on how to create an incident without a CI in this scenario 

1 ACCEPTED SOLUTION

Niklas Peterson
Mega Sage
Mega Sage

Hi @Naveen Bagula ,

sysparm_query parameter is not valid for the POST endpoint of the Table API. The parameter is used in the the GET endpoint to filter the query when fetching data. It will be ignored in the POST. 

Use the REST API Explorer to examine the valid parameters for the POST endpoint.

Regards,
Niklas

 

View solution in original post

2 REPLIES 2

Niklas Peterson
Mega Sage
Mega Sage

Hi @Naveen Bagula ,

sysparm_query parameter is not valid for the POST endpoint of the Table API. The parameter is used in the the GET endpoint to filter the query when fetching data. It will be ignored in the POST. 

Use the REST API Explorer to examine the valid parameters for the POST endpoint.

Regards,
Niklas

 

That is true. I resolved it with a business rule, Thank you!