Android Question okHttpUtils2 - HttpJOB unable to sent special chars "+"

Gianni Sassanelli

Active Member
Licensed User
Longtime User
Hi i need an help to send a string that in which is present a + character
i have tried with poststring and postbytes but unsuccessfully.

i have a log from webservice, seems that the + sended character is never received
if i send a string with postman utility all work fine

please help me thank's


sample code:
' sample 1
Dim hj As HttpJob
Dim mypar As String = "ws_parameter=A+B"
Dim bData() As Byte
dim wsEndpoint As String = "http://xxx.xxx.xxx.xxx/fn_1"
bData = mypar.GetBytes("UTF8")
hj.Initialize("j",Me)
hj.PostBytes(wsEndpoint,bData)   'KO  (from webServer log: ws_parameter = A B)
-----------------------
' sample 2
Dim hj As HttpJob
Dim mypar As String = "ws_parameter=A+B"

dim wsEndpoint As String = "http://xxx.xxx.xxx.xxx/fn_1"
hj.Initialize("j",Me)
hj.PostString(wsEndpoint,mypar)   'KO (from webServer log: ws_parameter = A B)

-----------------------
' sample 3
Dim hj As HttpJob
Dim mypar As String = "ws_parameter=A+B"  ' sending + as HTML encoded

dim wsEndpoint As String = "http://xxx.xxx.xxx.xxx/fn_1"
hj.Initialize("j",Me)
hj.PostString(wsEndpoint,mypar)   'KO'
-----------------------

' sample 4
Dim hj As HttpJob
Dim mypar As String = "ws_parameter=A\u002BB"  ' sending + as JS escape

dim wsEndpoint As String = "http://xxx.xxx.xxx.xxx/fn_1"
hj.Initialize("j",Me)
hj.PostString(wsEndpoint,mypar)   'KO'
-----------------------
 

Star-Dust

Expert
Licensed User
Longtime User
Replace + with %2B
 
Upvote 2
Cookies are required to use this site. You must accept them to continue using the site. Learn more…