Http 400 THE REQUEST URI DOES NOT MATCH THE APIS
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2022 11:11 AM
Hello,
When trying to do search, with automation to see if ticket has been created before and in open status with REST API, incident ticket with a jobname that has a # in the name. (like ISP00#B. This only happens with these type jobnames, all others are fine. I have code to include in the search endpoint ISP00>23B. It comes back with HTTP 400 THE REQUEST URI DOES NOT MATCH THE APIS. It works fine in our Dev servicenow environment.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2022 11:56 AM
Character # (like ? or &) has special meaning in a URL, so if the incident or job name is part of the URL, it must be escaped (JavaScript has function decodeURIComponent()
to do that).

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2022 04:14 PM
Hi Randy,
Replace "#" with "%23".
JavaScript function to encode url is encodeURIComponent().
var str = '#123';
var uri = "https://example.com/?product=" + encodeURIComponent(str);
gs.info(uri);
Execution result
*** Script: https://example.com/?product=%23123
FYI. Following page has a list of URL escape codes.
https://docs.microfocus.com/OMi/10.62/Content/OMi/ExtGuide/ExtApps/URL_encoding.htm