• Barry Peric
  • NEWBIE
  • 0 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies

I am trying to use the method EncodingUtil.urlEncode as shown below to encode a string passed into my method 'checkProduct'.  For example, if I call checkProduct('Jelly Beans'), I am expecting that the econdedURL would equal https://somewhere.com/something/Jelly%20Beans.  I am not getting that.  I am getting https://somewhere.com/something/Jelly++Beans.

 

What I need is for any of the spaces to be converted to %20.  I thought this is what the urlEncode method would do?  Any help would be appreciated.

 

public String checkProduct(String target) { String URL = 'https://somewhere.com/something/'; String encodedURL; System.debug('URL= ' + URL); encodedURL = URL + EncodingUtil.urlEncode(target, 'UTF-8'); System.debug('encodedURL= ' + encodedURL); )