- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-31-2020 07:58 AM
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
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-31-2020 05:23 PM
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!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-31-2020 05:20 PM
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-31-2020 05:23 PM
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!