Retrofit 2.4.0
retrofit = new Retrofit.Builder()
.baseUrl(BASE_URL)
.addConverterFactory(GsonConverterFactory.create())
.addCallAdapterFactory(RxJava2CallAdapterFactory.create())
.build();
I need to POST a List of objects and a list of pictures in the same request, like this :
@Multipart
@POST("api/debug/{id}/")
Call<ItemResponse> uploadItems(
@Path("id") int id,
@Part("items[]") List<Item> items,
@Part List<MultipartBody.Part> pictures);
Server side the list of items are not serialized correctly :
{
"items": [
"{"description":"desc1","id":1,"title":"title1"}",
"{"description":"desc2","id":2,"title":"title2"}",
"{"description":"desc3","id":3,"title":"title3"}"
],
"picture1": {
"name": "picture1",
"size": "315.777KB"
},
"picture2": {
"name": "picture2",
"size": "207.821KB"
}
}
The problem seems to be with using @Part.
What's the trick?