我在使用改装向服务器发送json对象体时遇到问题。以下是错误。
无法调用公开 com.nitesh.brill.saleslines._User_Classes.User_PojoClass.UpdatePreviousDetails() 没有args
代码段
// Api端点
@Headers("Content-Type: application/json")
@POST("UpdatePreviousDetails/{Id}")
fun updatePreviousDetails(@Path("Id") Id: Int, @Body updateDetails :UpdatePreviousDetails): Call<UpdatePreviousDetails>
// pojo class
package com.nitesh.brill.saleslines._User_Classes.User_PojoClass
import java.util.*
/**
* Created by Nitesh Android on 16-08-2017.
*/
class UpdatePreviousDetails(
var CompanyName: String? = null!!,
var Designation: String? = null!!,
var DateOfJoin: Date? = null!!,
var DateOfLeaving: Date? = null!!,
var SectorPreviouslyWorked: String? = null!!,
var Id: Int? = null!!
) {
}
//发送数据
val details = UpdatePreviousDetails("rr", "asm", date, date, "Pharmaceuticals",3)
val call = apiEndpointInterface!!.updatePreviousDetails(5, details)
call.enqueue(object :Callback<UpdatePreviousDetails> {
override fun onResponse(call: Call<UpdatePreviousDetails>?, response: Response<UpdatePreviousDetails>?) {
objUsefullData.showSnackBar("success")
UsefullData.Log("============="+response!!.body().toString())
}
override fun onFailure(call: Call<UpdatePreviousDetails>?, t: Throwable?) {
objUsefullData.showSnackBar("fail")
UsefullData.Log("============="+t)
}
})
我正在使用kotlin语言
答案 0 :(得分:0)
你的var router = express.Router();
require('./auth.js')(express, mongoose, router);
app.use(router);
类必须有一个没有参数的构造函数才能启用Gson(在Retrofit中)将你的对象转换为JSON。
修改强>
UpdatePreviousDetails