Using Retrofit 2.0.1, there is a call function in my API interface defined in Android App:
@Multipart
@POST(\"api.php\")
Call doAPI(
@Part(
If you would rather not use a converter, here's what I did to send a multipart request containing an image file, and 2 strings:
@Multipart
@POST("$ID_CHECK_URL/document")
fun postMultipart(@Part imageFile: MultipartBody.Part, @Part string2: MultipartBody.Part, @Part string2: MultipartBody.Part)
And calling it this way:
val body = RequestBody.create(MediaType.parse("image/jpg"), file)
val imageFilePart = MultipartBody.Part.createFormData("file", file.name, reqFile)
val string1Part = MultipartBody.Part.createFormData("something", "string 1")
val string2Part = MultipartBody.Part.createFormData("somethingelse", "string 2")
service.postDocument(imageFilePart, string1Part, string2Part)