Http 400 THE REQUEST URI DOES NOT MATCH THE APIS

RandyK
Mega Contributor

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. 

 

2 REPLIES 2

-O-
Kilo Patron

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).

Hitoshi Ozawa
Giga Sage
Giga Sage

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