0

I'm trying to send a request using Retrofit that I want to include a multi-part and Header and a JSON body but I'm getting the following error:

java.lang.IllegalArgumentException: @Body parameters cannot be used with form or multi-part encoding. (parameter #2)

@POST("add/department/loginId/{id}")
@Multipart
fun addDepartment(
    @Path("id") loginId: String,
    @Body department: Department,
    @Part multipartFile: MultipartBody.Part?,
    @Header("Authorization") authHeader: String?
): Observable<ArrayList<Department>>
Pylyp Dukhov
  • 38,521
  • 10
  • 57
  • 92
ali
  • 1
  • 3
  • Have a look at this https://stackoverflow.com/a/64119571/7093155 My best guess is that you are sending department as part of a `form-data` response. This is the best way to structure it – Robin Dec 02 '21 at 20:56

0 Answers0