cancel
Showing results for 
Search instead for 
Did you mean: 

Replacing + character with %2B when sending

SOLVED
Highlighted
Occasional Contributor

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'.

2 ACCEPTED SOLUTIONS

Accepted Solutions
Highlighted
Community Hero

Re: Replacing + character with %2B when sending

You may use Events feature beforeSubmit method and conditionally replace the value.


Regards,
Rao.

View solution in original post

Community Hero

Re: Replacing + character with %2B when sending

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
if this helped answer the post, could you please mark it as 'solved'? Also if you consider whether the title of your post is relevant? Perhaps if the post is solved, it might make sense to update the Subject header field of the post to something more descriptive? This will help people when searching for problems. Ta

View solution in original post

5 REPLIES 5
Highlighted
Community Hero

Re: Replacing + character with %2B when sending

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?


Regards,
Rao.
Highlighted
Occasional Contributor

Re: Replacing + character with %2B when sending

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>

Highlighted
Community Hero

Re: Replacing + character with %2B when sending

You may use Events feature beforeSubmit method and conditionally replace the value.


Regards,
Rao.

View solution in original post

Community Hero

Re: Replacing + character with %2B when sending

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
if this helped answer the post, could you please mark it as 'solved'? Also if you consider whether the title of your post is relevant? Perhaps if the post is solved, it might make sense to update the Subject header field of the post to something more descriptive? This will help people when searching for problems. Ta

View solution in original post

Highlighted
Community Manager

Re: Replacing + character with %2B when sending

richie, nmrao - great job here!

 

Hi @Pabe1975, please let us know if the suggestions helped! 



Sonya Mihaljova
Community and Education Specialist

 Join SmartBear Connect next April in Boston to meet with software development, API and testing experts from around the world! Get your ticket today!