You can't do a JSON body and a Multipart body in one HTTP request.
you can send your json as a parameter :)
// first create your json object
JsonObject object = new JsonObject();
object.addProperty("note_name", "your value goes here");
object.addProperty("description", "your description goes here");
// add other stuffs here
//create list of files to upload
List<Part> files = new ArrayList<>();
for (int i = 1; i <= 3; i++) {
files.add(new FilePart("file" + i, new File("path of file like: storage/image/....")));
}
Ion.with(context)
.load("POST","http://example.com")
.uploadProgress(new ProgressCallback() {
@Override
public void onProgress(long downloaded, long total) {
int percent = (int) (downloaded * 100 / total);
// update your progressbar with this percent if needed
}
})
.addMultipartParts(files)
.setMultipartParameter("json", object.toString()) // your json is here
.asString()
.setCallback(new FutureCallback<String>() {
@Override
public void onCompleted(Exception e, String result) {
if (e != null) {
// error: log the message here
return;
}
if (result != null) {
// result is the response of your server
}
}
});
Hope this help you :)