Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/kotlin/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 无法为类创建@Body转换器_Android_Kotlin_Retrofit2 - Fatal编程技术网

Android 无法为类创建@Body转换器

Android 无法为类创建@Body转换器,android,kotlin,retrofit2,Android,Kotlin,Retrofit2,当我调用post-api时,我试图使用改型来调用它 无法为类CreateOrderRequest创建@Body转换器(参数#1) 对于方法CheckOutService.createOrder @WorkerThread suspend fun createOrderService(body: CreateOrderRequest) { if (networkAvailable()) { val retrofit = Retrofit

当我调用post-api时,我试图使用改型来调用它

无法为类CreateOrderRequest创建@Body转换器(参数#1) 对于方法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)
        }
    }
模型

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
)

我有完全相同的问题,你能找到解决方案吗?我有完全相同的问题,你能找到解决方案吗?
interface CheckOutService {
    @POST("createOrder")
    suspend fun createOrder(@Body user: CreateOrderRequest)
}