Skip to content Skip to sidebar Skip to footer

Error While Sending Json Data To Server With Base64 Encoded Image String

in my code i am sending the json data like this ByteArrayOutputStream baos = new ByteArrayOutputStream(); imgbmp.compress(Bitmap.CompressFormat.PNG, 90, bao

Solution 1:

i got the answer... i was not making any kind of mistakes

that was problem with org.json

i switched to another..and all it works

nesting too deep in JSON... should I switch to XML?

Solution 2:

Looking at your code, you are using enimg to add the image data to your JSON and not encodedImage. If this is a cut & paste error in your question, then I suspect that there may be a problem in your Base64 encoding. Have you tried using the encodeToString() method of android.util.Base64 instead?

Even if you need to support API versions earlier than 8, this will prove whether it's a Base64 error, and once you've determined that you'll know what you have to fix.

Solution 3:

Don't pass files/images with json. You will get "out of memory" errors if files/images are big.

Post a Comment for "Error While Sending Json Data To Server With Base64 Encoded Image String"