I have an ArrayList of Integers that I need to put into my MultipartBody.Builder. I have tried using different methods of .addFormDataPart, even tried to convert the arraylist to a JSONObject and then the JSONObject to a string, but my server would return an error like:
{"tags":["Incorrect type. Expected pk value, received str."]}
My json on the server is formatted like this
{"id":1,
"tags" : [
{"id":1},
{"id":2}
]
}
and in android studio I am trying to put in an ArrayList of integers that contain the tags id's like this
okhttp3.RequestBody fileRequestBody = RequestBody.create(MediaType.parse("text/csv"), file);
okhttp3.RequestBody requestBody = new MultipartBody.Builder()
.setType(MultipartBody.FORM)
.addFormDataPart("id", projecID)
.addFormDataPart("tags", tagIDArray")
.addFormDataPart("file", "file", fileRequestBody).build();