I'm trying to upload some data to the API using form-data request type. I used the @Multipart annotation in the retrofit interface and @Part in the fields. But server is throwing the error. Okhttp code for the same is working fine.
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("text/plain");
RequestBody body = new MultipartBody.Builder().setType(MultipartBody.FORM)
.addFormDataPart("content", “save this text”)
.addFormDataPart(“id”, “111”)
.build();
Request request = new Request.Builder()
.url("https://myurl”)
.method("POST", body)
.addHeader("Authorization", "Bearer token”)
.build();
Response response = client.newCall(request).execute();
How can we do the same with Retrofit?