I'm using JSON
with REST
api for using web service.
Now I also need to send Images in request. Is it possible?
If yes, what changes do I need to do on client/server side.
And in my Java code, how should I send the image content (do I need to set a content type separately)?
You should not send the image itself, but url from which it can be downloaded.
Otherwise:
AndroidObject
Sample app side code that worked for me. You can send image in one valuepair and the json in another valuepair: (Here "uploadedfile" tag defines the valuepair as the path of the image file in sd card during checking in post function, other tags will be considered as text data)
// Post Function
Apache Mime4J, HTTPCore, HTTPMime libary jars need to be added to project
I use this code in my AsyncTask:
The way to do that would be to send it as content inside a HttpPost request as below
The way you would string encode the image would be to do the following.
Good luck