Outbound REST API special character not passing ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-10-2022 09:07 PM
Try to Test the REST API variable substitutions of special character (%) , its returns 500 error
and If we remove % , its inserted correctly
Its outside application issue where we inserting the record? or ServiceNow Issue?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-10-2022 09:30 PM
Hi,
It is the issue with the special character. Please use Escape type as with escape instead of "No escaping"
Thanks,
Narsing
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-10-2022 11:13 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2022 02:24 AM
Hello Sukran,
I am not sure on how you can pass the % in Rest message via variable substitution but if you try to call the Rest Message API via script and then pass the data that include % character in request body then it will not give an error. Please refer to the below script:
var requestBody = {"name": "ServerTesting1%"}; is the request body set in the below example and the Server is created with ServerTesting1% name in target instance.
(function () {
var tableName = "cmdb_ci_server";
var requestBody = {"name": "ServerTesting1%"};
var RESOURCE_PATH = "/api/now/table/cmdb_ci_server";
var request = new sn_ws.RESTMessageV2();
request.setEndpoint("https://<YOUR_INSTANCE_URL>.service-now.com/"+RESOURCE_PATH );
request.setHttpMethod('POST');
//request.setQueryParameter("sysparm_query", "name=ApplicationServerHelpdesk");
//Eg. UserName="admin", Password="admin" for this code sample.
var user = 'admin'; //replace your user name here
var password = 'admin'; // replace user's password here
request.setBasicAuth(user,password);
//gs.print(JSON.stringify(requestBody));
request.setRequestBody(JSON.stringify(requestBody));
request.setRequestHeader("Accept","application/json");
var response = request.execute();
var responseBody = response.getBody();
gs.print(responseBody);
})();
Please mark my respsone as helpful/correct, if it answer your question.
Thanks