Is there a "one of" query to retrieve value of a field thru' REST Table API?

Deepali5
Tera Contributor

How can I make a rest API call to query a record based on a query parameter that is not exact match but one of the values in a set?

e.g GET /api/now/table/user?sysparm_query=name(is one of)"value1,value2,balue3"

 

Thank you

1 ACCEPTED SOLUTION

Chaitanya Redd1
Tera Guru

Hi,

 

To make a REST API call to query a record based on a query parameter that is not an exact match but one of the values in a set, you can use the "IN" operator in the query parameter.

Here's an example REST API call to retrieve users whose name is one of "value1", "value2", or "value3":

GET /api/now/table/user?sysparm_query=nameINvalue1,value2,value3

The "IN" operator allows you to specify a comma-separated list of values to search for. In this example, the "nameIN" parameter is used to search for users whose names are one of the specified values.

Note that you do not need to enclose the values in quotes as the values are comma-separated. Additionally, you can use other operators such as "!=" or ">" to perform more complex queries.

Also, keep in mind that the "sysparm_query" parameter is case-sensitive, so make sure to use the correct case for the field name and operator.

View solution in original post

1 REPLY 1

Chaitanya Redd1
Tera Guru

Hi,

 

To make a REST API call to query a record based on a query parameter that is not an exact match but one of the values in a set, you can use the "IN" operator in the query parameter.

Here's an example REST API call to retrieve users whose name is one of "value1", "value2", or "value3":

GET /api/now/table/user?sysparm_query=nameINvalue1,value2,value3

The "IN" operator allows you to specify a comma-separated list of values to search for. In this example, the "nameIN" parameter is used to search for users whose names are one of the specified values.

Note that you do not need to enclose the values in quotes as the values are comma-separated. Additionally, you can use other operators such as "!=" or ">" to perform more complex queries.

Also, keep in mind that the "sysparm_query" parameter is case-sensitive, so make sure to use the correct case for the field name and operator.