【问题标题】:No Retrofit annotation found. (parameter #2)未找到改造注释。 (参数#2)
【发布时间】:2018-09-28 12:41:55
【问题描述】:

我在使用改造发送参数时遇到问题。请帮我解决这个问题。

这是界面:

@POST(Config.URL_PAYMENT)
fun sendPayment(@Body id:String, total: Long): Call<List<ProgressAntar>>

剩下的就这些了

private fun sendPayment(id: String, total: Long){
    Log.i("getDataProgress", "dataProgress$id")

    val apiService : Service = Client.getClient()!!.create(Service::class.java)
    apiService.sendPayment(id,total).enqueue(object : Callback<List<ProgressAntar>> {

        override fun onResponse(call: Call<List<ProgressAntar>>?, response: Response<List<ProgressAntar>>?) {
            if (response != null && response.isSuccessful) {
                Log.i("tesSucess", "sucess" + response.body())
                val list = response.body()

                if (list == null || list.isEmpty()) {
                    Toast.makeText(activity, "Tidak ada daftar pembayaran", Toast.LENGTH_LONG).show()
                } else{
                    // refresh progress list
                    progressList = ArrayList(list)
                    dataProgressAdapter.updateData(progressList)
                }
            } else{
                Toast.makeText(activity, "Tidak ada daftar pembayaran", Toast.LENGTH_LONG).show()
            }
        }
    }

【问题讨论】:

    标签: java kotlin retrofit


    【解决方案1】:

    那是因为total: Long 没有注解,所以Retrofit 不知道如何将它转发到你的API。

    您可能需要@Field 而不是Body

    【讨论】:

    • 对我来说这是第 5 个参数没有注释。因此,请确保您使用@Body@Path ...等作为传递给服务接口函数的参数
    猜你喜欢
    • 1970-01-01
    • 2015-04-06
    • 2022-07-31
    • 2020-08-11
    • 1970-01-01
    • 1970-01-01
    • 2022-01-03
    • 2017-08-26
    • 1970-01-01
    相关资源
    最近更新 更多