I m trying to make a request in which I want to include a Header , a form-urlencoded field and a json body. My Retrofit interface is as follows
@FormUrlEnc
Adding to Julien's answer, also remove the @Multipart
annotation. Here's how I have used it:
@POST("/app/oauth/token")
Call getAuthToken(@Body RequestBody body);
And, here is how I have constructed the RequestBody
:
RequestBody requestBody = new MultipartBody.Builder()
.setType(MultipartBody.FORM)
.addFormDataPart("grant_type", "password")
.addFormDataPart("username", username)
.addFormDataPart("password", password)
.build();