You need to sign in to do that
Don't have an account?

How to avoid URL encoding of ampersand
Just a quick question: How do I avoid urlencoding an ampersand (the '&' character). I wish to make a URI with parameters - the parameters are separated by ampersands, but they get encoded automatically (i.e., '&' goes to '&').
The code looks like
<apex:iframe src="https://some-domain.com/action?a={!value1}&b={!value2}"/>
where value1 and value2 are attributes on my controller. The ampersand in between the two parameters is causing me trouble...
I would have expected that only application of the URLENCODE function would result in this substitution, but this is not the case. The '&' character is substituted without it.
All help is appreciated. Thank you!
Use EncodingUtil.urlEncode(url, 'UTF-8'); method.
This code will help you to resolve your issue.
Try:
String str1 = EncodingUtil.urlEncode(Value1, 'UTF-8');
String str2 = EncodingUtil.urlEncode(Value2, 'UTF-8');
and pass str1 and str2 in url then it will work find.
because you are passing the value1 or value with the combination of & that why you are getting the eroor message.
Actually, that is the correct means of encoding an ampersand in HTML. Your problem lies elsewhere.
Proof:
Google.com
Try my link above, you'll see that the & is properly decoded into an & when your browser goes to the page.
Edit: So, like, I should probably say, you're NOT encoding value1 nor value2. Depending on the contents of those values, that would cause your grief.
Edit 2: The forums are junking up my code. But the fact is, you're supposed to use character entities for ampersand, quote, less-than, and greater-than in any url in HTML.