function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
dannapareddy1.3909373019751619E12dannapareddy1.3909373019751619E12 

String Error

Hi All, 

I am constructing a string with pipe in string . I get the HTML code of the string . please let me know how to get around this 



Execute Anonymous: String s1 = 'https://XXXX.com/deals/search?q=createdBefore:2011-12-30|status:XXXXX|city:XXXX';
Execute Anonymous: system.debug(s1);
16:17:38.038 (38016569)|EXECUTION_STARTED
16:17:38.038 (38030801)|CODE_UNIT_STARTED|[EXTERNAL]|execute_anonymous_apex
16:17:38.038 (38922735)|SYSTEM_METHOD_ENTRY|[3]|System.debug(ANY)
16:17:38.038 (38963804)|USER_DEBUG|[3]|DEBUG|https://XXXX.com/deals/search?q=createdBefore:2011-12-30|status:XXXXX|city:XXXX
16:17:38.038 (38982944)|SYSTEM_METHOD_EXIT|[3]|System.debug(ANY)



The pipe in the string is being changed to |

please help me get around this .This is the endpoint URL i need to make an webservice call out
Balaji Chowdary GarapatiBalaji Chowdary Garapati
Try using EncodingUtil.urlEncode(String,'UTF-8') method to convert your URL.

 
dannapareddy1.3909373019751619E12dannapareddy1.3909373019751619E12
Once i Encode using UTF-8

https%3A%2F%2FXXXXXXX%2Fdeals%2Fsearch%3Fq%3DcreatedBefore%3A2011-12-30%7Cstatus%3AXXX%7Ccity%3AXXXX


when i decode back 
I end up at the same point
https://XXXXXXXX/deals/search?q=createdBefore:2011-12-30|status:XXX|city:XXXX