New Member.

Convert Actual XML in url encoded ascii format

I am using REST API for our performance testing. Once we are able to deal with SLL we have to send the actual XML in server accepting format.

 Server is design in that way it will accept only url encoded ascii format. So, we have to convert actual xml to url encoded ascii format and replace "\\+" with "%20". 

Below piece of code we are uinsg while automation.
 "XML=" + (java.net.URLEncoder.encode(actual, "ASCII").replace("\\+", "%20")).trim();

Can any one help me how to perform same task through LR Scripting.


1 Reply
Acclaimed Contributor.. Acclaimed Contributor..
Acclaimed Contributor..

Re: Convert Actual XML in url encoded ascii format

You can use the function web_convert_param(), take as target encoding URL.

When you want to convert a '+' to %20 in the result you have to manually fix that with some C functions.

You might not need that, depending on how you perform your decoding at your server. When your server is using java.net.URLDecoder.decode(), you will be fine.

Reward community members who take time to respond and help.
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.