sysparm_query not working for strings with spaces

Abu Fazal Abbas
Kilo Explorer

Hi,

I am trying to retrieve the sys_id using REST API call. To filter the records, I am using sysparm_query; however, the filter condition doesn't work if the string contains any spaces in between.

$ curl "https://dev101959.service-now.com/api/now/table/cmdb_rel_type?&parent_descriptor=Hosted On&sysparm_fields=sys_id" --request GET --user 'admin':'********' 2>/dev/null

AbuFazalAbbas@D66XCK72 MINGW64 ~
$

 

Any idea, how can I make the filter condition to work for strings with spaces in between?

 

Thanks,

Abbas

1 ACCEPTED SOLUTION

Allen Andreas
Administrator
Administrator

Hi,

Check this out for any future reference in regard to URL ASCII: https://www.w3schools.com/tags/ref_urlencode.ASP

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

View solution in original post

2 REPLIES 2

Mike Patel
Tera Sage

you need something like (you will have to encode fitler keywords before sending it to rest api). use encodeURIComponent()

 

$ curl "https://dev101959.service-now.com/api/now/table/cmdb_rel_type?&parent_descriptor=Hosted%20On&sysparm_fields=sys_id" --request GET --user 'admin':'********' 2>/dev/null

Allen Andreas
Administrator
Administrator

Hi,

Check this out for any future reference in regard to URL ASCII: https://www.w3schools.com/tags/ref_urlencode.ASP

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!