i'm trying to call post api using retrofit when i call it i got
Unable to create @Body converter for class CreateOrderRequest (parameter #1) for method CheckOutService.createOrder
@WorkerThread
suspend fun createOrderService(body: CreateOrderRequest) {
if (networkAvailable()) {
val retrofit = Retrofit
.Builder()
.baseUrl(BASE_URL)
.addConverterFactory(MoshiConverterFactory.create())
.build()
val service = retrofit.create(CheckOutService::class.java)
service.createOrder(body)
}
}
Models
data class CreateOrderRequest(
val cardItem: ArrayList<JSONObject>,
val deliveryCost: String,
val deliveryTime: String,
val lat: String,
val long: String,
val name: String,
val note: String,
val paymentMethod: String,
val phone: String,
val status: String,
val subTotal: String,
val timeStamp: JSONObject,
val total: String
)
data class CardItem(
val categoryID: String,
val detailes: String,
val hasDiscount: Boolean,
val image: String,
val inStock: Boolean,
val name: String,
val oldPrice: String,
val price: String,
val productID: String,
val qty: String,
val variant: String,
val subCategoryID: String,
val subSubCategoryID: String
)
here is the service
interface CheckOutService {
@POST("createOrder")
suspend fun createOrder(@Body user: CreateOrderRequest)
}