Notifications

38 views

Description

Special characters in languages like French or Arabic that are sent in resource path parameters to scripted REST API (setRedirectURL) are not passed correctly and do not properly encode values.

Steps to Reproduce

1. Create a UI action on the incident table with the following details:
Name: Copy Short Description to new Incident
Form Link: checked
Script:
var sd = current.short_description.toString();
action.setRedirectURL("incident.do?sys_id=-1&sysparm_query=short_description=" + sd);

2. Create a new incident.

3. Set the value of short description to: Québécois.

4. Save the record.

5. Click on the UI Action form link created in step1. The short description does not display the special characters properly.

 

6. Create a scripted REST API
Example end point: /api/snc/hello_nonascii_world/{pathParamValue}
Script:
(function process(/*RESTAPIRequest*/ request, /*RESTAPIResponse*/ response) {
gs.log("request.uri: " + request.uri); // < bad chars here
var pathParams = request.pathParams;
var pathParamValue = pathParams.pathParamValue;
gs.log("pathParamValue="+pathParamValue); < bad chars here
})(request, response);

7. Send request to this point with Arabic characters as path parameter:
curl "https://INSTANCE.service-now.com/api/snc/hello_nonascii_world/طالب" --header "Accept:application/json" --user 'admin':'xxxxxxxx' --verbose

Instance logs print invalid characters:
request.uri: /api/snc/hello_nonascii_world/طالب
pathParamValue=طالب

Workaround

This problem is under review and targeted to be fixed in a future release. To receive notifications when more information becomes available, subscribe to this Known Error article by clicking the Subscribe button at the top right of this form.

As a workaround, send the special characters as query parameters instead of path parameters. For example:
curl "https://INSTANCE.service-now.com/api/snc/hello_nonascii_world/pathParamValue?nonasciivalue=طالب" --header "Accept:application/json" --user 'admin':'xxxxxxxxxx' --verbose

Example REST API script:
(function process(/*RESTAPIRequest*/ request, /*RESTAPIResponse*/ response) {
var queryParams = request.queryParams;
gs.log("queryParamTest="+queryParams.nonasciivalue);
})(request, response);


Related Problem: PRB1327177

Seen In

There is no data to report.

Associated Community Threads

There is no data to report.

Article Information

Last Updated:2019-08-06 11:19:32
Published:2019-08-06