I'm using retrofit to connect to server which needs authorization token in POST Data. Example For the request:
https://adress/inboxes
POST data:
token=jasdf807gb123uy40bviubva08sdyv123&message_id=1&
I use method like this and its works fine:
@POST("/inboxes")
Call<InboxesResponse> getInbox(@Header("Authorization") String authorization, @Header("Content-Type") String contentType, @Body RequestBody body);
I put token and other parameters into RequestBody:
RequestBody body =
RequestBody.create(MediaType.parse("text/plain"), text.toString());
All this works fine. But i cant figure out how to work with file uploading method:
Example:
https://adress/fileUpload
POST data:
token=jasdf807gb123uy40bviubva08sdyv123
File body
So i need to use MultipartBody.Part file
to upload file, but how to combine MultipartBody with RequestBody which contains token? Or how to do this right? i'm confused..