I have an API which expects a list of exercises as input:
exercises[0][duration]=10
exercises[0][type]=jump
exercises[1][duration]=20
exercises[1][type]=roll
On Android side, I have my API class built using Retrofit.
How do I pass my List<Exercise>
to the API method in order to get the above parameters.
Currently tried:
@FormUrlEncoded
@POST("api/v1/patient/{id}/workout")
fun addPatientWorkout(@Path("id") id: Long,
@Field("title") title: String,
@Field("exercises[]") exercises: List<Map<String,String>>)
: Single<Response<Workout>>
But that does not give what I expect. Instead:
exercises[]={duration:10, type=jump}&exercises[]={duration:20, type=roll}