Forum Discussion

Pabe1975's avatar
Pabe1975
Occasional Contributor
5 years ago
Solved

Replacing + character with %2B when sending

When sending a http request with a + in the a field (in this case a field that contains an international phone number with + XX XXXX) the + is replaced with a space.

 

However in the receiving endpoint needs the +, is there a way to replace the + with %2B so a + character is sent to the receiver ?

 

We don't want the %2B in the field as it confuses people so we want to handle this issue 'behind the screens'.

  • nmrao's avatar
    nmrao
    5 years ago
    You may use Events feature beforeSubmit method and conditionally replace the value.
  • Hi Pabe1975,

    Rao's correct (as always), but your + character is being encoded (percent/html encoding) to %2B.

    This is standard html encoding that occurs in all HTTP requests (Rest and Soap), so if an endpoint is struggling with the encoding, especially as you state that the %2B is being replaced by a space character instead, i'd suggest this is a defect and your developers need to be aware of this. Mention percent/html encoding and theyll know what youre talking about.
    If you want to disable the percent encoding there is a checkbox entitled 'Disable encoding' which is available in the 'Advanced options' available at 'Request' level in the Projects section of ReadyAPI!.
    Just an alternative option to Raos.

    Nice one

    Rich

5 Replies

  • nmrao's avatar
    nmrao
    Champion Level 3
    Is it a REST test step you are doing?
    Are you sending the data in post request?
    Is it possible to show with screen shot raw request?
    • Pabe1975's avatar
      Pabe1975
      Occasional Contributor

      Hi nmrao;

       

      It is a soap request I am sending. Yes it is a POST (see snippet). In the RAW the + is still visible however when processing it in a HTTP JMS Gateway the + is translated to a space character.

       

      A snippet of the post:

      POST http://localhost:XXXX?q=XXX.XXXXXX.XXXX.Aanvraag.1.XX.Queue&token=XXXXXX HTTP/1.1
      Accept-Encoding: gzip,deflate
      Content-Type: application/soap+xml;charset=UTF-8;action="XXXXXXXX"
      Content-Length: 10458
      Host: localhost:20511
      Connection: Keep-Alive
      User-Agent: Apache-HttpClient/4.5.2 (Java/1.8.0_181)

      .

      .

      .

      .

       

      <Naam>Dhr. R. Pleaseman</Naam>
      <Emailadres>regressiezakelijk1@lip.woesap.com</Emailadres>
      <TelefoonnummerMobiel>00+31 (0)6-29 60 01 163</TelefoonnummerMobiel>
      <NotificatieVoorkeur>GEEN</NotificatieVoorkeur>
      <ContactKenmerk>Contactpersoon Uitvoering</ContactKenmerk>

      • nmrao's avatar
        nmrao
        Champion Level 3
        You may use Events feature beforeSubmit method and conditionally replace the value.