hi, i am build Point Of Sales apps and i can’t able to send multiple json object in json array. in my case, my apps read from database (SQLite) and send selected products to server.
anyone help me ? thanks
Logcat
E/Volley: [893] BasicNetwork.performRequest: Unexpected response code 422 for https://…
override fun getHeaders(): MutableMap<String, String> {
val headers = HashMap<String, String>()
headers["Accept"] = "application/json"
headers["Content-Type"] = "application/x-www-form-urlencoded"
headers["Authorization"] = "Bearer " + user_info.token
return headers
}
override fun getParams(): MutableMap<String,String> {
val cartRepository = CartRespository(application)
val transaksi = cartRepository.getByIdTrans(id_trans)
val jo = JSONObject()
val ja = JSONArray()
for(i in 0 until transaksi.size){
ja.put(i,jo.put("product_id", transaksi[i].id_item))
ja.put(i,jo.put("jumlah", transaksi[i].kuantitas).toString())
}
val map = HashMap<String, String>()
map.put("rfid", "122312")
map.put("device", user_info.device)
map.put("products", ja.toString())
return map
}