Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android webview.postUrl(url,Encodingutils.getBytes(postData,"BASE64")) removing "+" from the postdata String

I am posting from a Webview to the https server as shown in the below URL with BASE64 as charset.

Send data to page loaded in WebView

My postdata string is a Base64 encoded string with "+" in it.

When i am posting in the way as shown in the above URL, server log shows postdata string with a missing "+"

I should be able to post any data string from the Webview because i will be posting a Base64 Encoded string on which i don't have control.

Please help me solve this issue.

Update:I even tried like this

String postData = "fileContents=" + fileCon;

 mWebView.postUrl(url,postData.getBytes());

But still "+" is removed from postData when it is posting.If there is no "+" in the postData, it posts correctly.

like image 533
Sreeram Avatar asked Jan 29 '26 05:01

Sreeram


1 Answers

The + is a special character in URLs and represents a space. You need to URL-encode the parameter value before sending it.

String postData = "fileContents=" + URLEncoder.encode(fileCon, "UTF-8");
like image 139
BalusC Avatar answered Jan 30 '26 18:01

BalusC