I need somebody help for this case: Here the format of my object :
{
"transport": true,
"fraisTransport": "string"
"cars": [
{
"id": "string",
"prix": "string",
"photo_url1" : "string",
"photo_url2" : "string"
},
{
"id": "string",
"prix": "string",
"photo_url1" : "string",
"photo_url2" : "string"
}
]
}
Here is my Api interface
@Multipart
@POST("declaration")
fun addDeclaration( @Part carsImage: Array<MultipartBody.Part> ,
@Part propertyCars: MultipartBody.Part,
@Part dataDeclaration: RequestBody): Observable<Response>
here how i set the variable for dataDEclaration
val jsonObject = JSONObject()
jsonObject.put("transport", declaration.transport)
jsonObject.put("frais_transport", declaration.fraisTransport)
val bodyDeclarationInfo = jsonObject.toString().toRequestBody("application/json; charset=utf-8".toMediaTypeOrNull())
Now my problem is how to set the variable for cars objects. Please any suggestions will welcome. Thanks