How can I post following parameter in retrofit through post method ?
\"params\":{\"body\": {
\"learning_objective_uuids\": [
\"ED4FE2BB2008FDA9C81
Gson is the Best solution for JSON Object/Array related problems.
Here, I am sharing my easiest solution for passing array type value in retrofit API
id: ArrayList<String> //Already initilized
status: String //Already initilized
val jsonObject = JsonObject()
val toJson = Gson().toJsonTree(id) //Only one line to covert array JsonElement
jsonObject.add("id", toJson) //Add Json Element in JsonObject
jsonObject.addProperty("status", status)
API Calling using jsonObject
@POST("API_END_POINT")
fun changeStatusOfList(@Body jsonObject: JsonObject): Observable<Response<RETURN_TYPE>>
Output in Log:
{"id":["426","427"],"status":"1"}