Query the rest api with spaces in the query

Wietse Sas
Kilo Contributor

I have a table with a field ip_address.
The ip_address field can contain multiple ip addresses, seperated by a space.

I want (with the REST API) to get only items that contain a specific ip address.

I tried with (%20 is a space):

  • Equals ipaddress OR
  • StartsWith ipaddress%20 OR
  • EndsWith %20ipaddress OR
  • Contains %20ipaddress%20

But it seems the server trims everything and my spaces are not included in the query... A good thing, except if you want beginning or trailing spaces in your query...

Anyone an idea on how to solve this?

3 REPLIES 3

Masarrat Siddi1
Kilo Guru

Why do you want to send white space? if you are searching for a single ip address, simply send that ip address to your REST without any space. Let's understand with a simple example

you are having ip lists as [ 123.12.125.34 99.98.97.96, 221.222.222.223 ] and you want to search for 99.98.97.96, then just send this ip address 99.98.97.96 without any space. don't worry about the white spaces.

 

 

 

Thank You!

 

Wietse Sas
Kilo Contributor

I think you misunderstood.

IP's are seperated by a space, for example "192.168.0.1 10.3.220.1 2001:0db8:85a3:0000:0000:8a2e:0370:7334".

If I query for 192.168.0.1 without the whitespaces and using LIKE, i get results for:

192.168.0.1
192.168.0.10
192.168.0.11
192.168.0.12
...

I cannot query with a space, since spaces on the beginning of a string and the end of a string are trimmed by ServiceNow.

 

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Sas,

the contains operator should work.

for example: you want to get record where ip address contains 10.3.220.1

what the above result give you?

Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader