How to resolve Invalid Url problem

Hi,

This is vignesh. Recently we have come across a problem that When we send a request from Salesforce to Aspose for document merging,it says Invalid Url. We analysed this issue and found that it is working when all the characters in URL are in english but if the path of the URL has chinese characters as a word and the URL is set as End Point to Aspose, Aspose throws error saying it is bad response because of Invalid URL.The error is shown as follows

Bad Request

Bad Request - Invalid URL


HTTP Error 400. The request URL is invalid.

The Url we set as EndPoint to Aspose is 
https://api.aspose.com/v1.1/words/阿德里安娜鲁伊斯/executeTemplate?cleanup=ContainingFields,EmptyParagraphs,UnusedFields,UnusedRegions,RemoveTitleRow,RemoveTitleRowInInnerTables&appSID=e8c4f52b-f08b-456f-ad91-6ec71c2a1896&signature=C2E%2BmrFIeDNUF6z%2Fv1TJOKVsgWI
(Please have a look at the green highlighted mark in the Url and it is in Chinese.
The source code we used to send request to Aspose is as follows.
 public static Blob ProcessCommand(String strURI, String strHttpCommand,  String ContentType) {
        try {
            HttpRequest request = new HttpRequest();
            Integer len = 0;
        request.setEndpoint(strURI);
        request.setMethod(strHttpCommand);

        if (ContentType.toLowerCase() == 'xml'){
            request.setHeader('Content-Type', 'application/xml');
        }else if (ContentType.toLowerCase() == 'json'){
            request.setHeader('Content-Type', 'application/json');
        }else{
        	request.setHeader('Content-Type', 'MultiPart/Form-Data');
        }
        request.setHeader('Content-Length', String.valueOf(len));
        request.setHeader('Accept', 'application/json');
        request.setTimeout(99999);
		if(TEST.isRunningTest() ){
        	return Blob.valueOf('This is for Test');
        } else{
        	Http http = new Http();
            HttpResponse res = http.send(request);
            return res.getBodyAsBlob();
        }
        
    } catch (Exception ex) {
        system.debug('HTTP ERROR' + ex.getMessage());
        throw new DataSourceException('ASPOSE Service Exception : '+ex);
        return null;
    }
}</font></span></pre><pre class="codeBlock" style=""><font face="Courier New, Courier, mono"><span style="font-size: 12px; background-color: rgb(255, 255, 255);">Can you please tell me whether Url can have chinese character like i showed above? </span></font></pre><pre class="codeBlock" style=""><font face="Courier New, Courier, mono"><span style="font-size: 12px; background-color: rgb(255, 255, 255);">If so, can you please tell me how to modify my code in a way it will support Url with chinese characters?</span></font></pre><pre class="codeBlock" style=""><font face="Courier New, Courier, mono"><span style="font-size: 12px; background-color: rgb(255, 255, 255);"><br></span></font></pre><pre class="codeBlock" style=""><font face="Courier New, Courier, mono"><span style="font-size: 12px; background-color: rgb(255, 255, 255);">Thanks.</span></font></pre><pre class="codeBlock" style=""><font face="Courier New, Courier, mono"><span style="font-size: 12px; background-color: rgb(255, 255, 255);"><br></span></font></pre><pre class="codeBlock" style=""><font face="Courier New, Courier, mono"><span style="font-size: 12px; background-color: rgb(255, 255, 255);"><br></span></font></pre></pre></div>

Hi Vignesh,


Thanks for your inquiry. Could you please attach your input Word document and JSON/XML data file here for testing? We will investigate the issue on our end and provide you more information.

Best regards,

Hi,

We are not able to generate JSON string for file with chinese name as we are getting following exception:
<span style=“font-family: “Courier New”, Courier, mono; font-size: 12px; background-color: rgb(248, 248, 248);”>ASPOSE Merge Service Exception : System.JSONException: no content to map to Object due to end of input

I am attaching JSON string generated from English filename and the sample document template.

When we pass strURI to ProcessCommand function (refer first comment)then it returns System.HttpResponse[Status=Forbidden, StatusCode=403] and response body is blank for Chinese name whereas for English name it returns System.HttpResponse[Status=OK, StatusCode=200] and response body is not blank.


Thanks

Hi Vignesh,


Thanks for your inquiry. After an initial test with Aspose.Words for Cloud, I was unable to reproduce this issue on my side. Please create a standalone runnable Java application (source code without compilation errors) that helps us reproduce your problem on our end and attach it here for testing. Thanks for your cooperation.

Best regards,