Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to send encoded Base64 image string to server using JSON object

Tags:

android

I am new in android . i have send image to server using Json format as a string.

so i have Encoded image string i.e base64 string.

 Json j =  new JSonObject();

String Image_string = Base64.ToEncodedString(bytearray, Base64.Default);

j.put("image_file_content",Image_string);

But i am getting this error. Please help me..wts wrong

400 Bad Request

Bad Request

Your browser sent a request that this server could not understand.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

like image 329
Pravin Mohol Avatar asked Jan 25 '12 08:01

Pravin Mohol


1 Answers

Consider using URLEncoder

URLEncoder.encode("String to encode", "UTF-8");

Check out the docs here: http://developer.android.com/reference/java/net/URLEncoder.html

like image 110
iko_wp Avatar answered Sep 30 '22 02:09

iko_wp