I trying to do that a few days, and I really did everything.. Here is how request looks in Postman:
I am sure, that all GET parameters were writing correctly.
I spent a lot of time to search, how to send a file as byte-stream because all answers in web explain upload via RequestBody, but it's not working for my case. So, here is the solution:
InputStream in = new FileInputStream(file);
byte[] buf = new byte[in.available()];
while (in.read(buf) != -1) ;
RequestBody requestBodyByte = RequestBody
.create(MediaType.parse("application/octet-stream"), buf);
String content_disposition = "attachment; filename=\"" + fileName + "\"";
//GET parameters
Map params = new HashMap();
params.put("inspectionUUID", inspectionUUID);
params.put("noteUUID", noteUUID);
params.put("attachmentUUID", attachmentUUID);
params.put("noteType", noteType);
params.put("modifiedTime", modifiedTime);
Call call = service.upload(access_token, content_disposition, requestBodyByte, params);
Interface:
@POST("api/MediaFiles/AddMediaFile")
Call upload(
@Header("Authorization") String authorization,@Header("Content-Disposition") String content_disposition, @Body RequestBody photo,
/* GET params */ @QueryMap Map params
);