I need to send a POST with Retrofit:
Retrofit.Builder()
.baseUrl(API_BASE_URL)
.addConverterFactory(
GsonConverterFactory.create(
GsonBuilder().serializeNulls().create()
))
.client(okHttpClient)
.build()
@POST(endpoint)
@FormUrlEncoded
fun partialPickupsDelivery(
@HeaderMap headers: Map<String, String>,
@Field("userId") userId: String,
@Field("purchaseIds[]") purchases: ArrayList<String>
): Call<ResponseBody>
The server is waiting something like this:
purchaseIds=["1234", "2345", "3456"]
The problem comes when I try to send an empty array (not null) because the server is waiting:
purchaseIds=[]
But I'm sending only the first param userId (I think retrofit is removing the second one because the array is empty).
Is there any way to send purchaseIds=[]?
Thx
partialPickupsDeliveryis called?@Field("purchaseIds[]")this is not the way of calling array.