下图是在邮递员上运行良好的 whatsap api 的响应。
但是当我尝试通过使用改造在 android 项目上运行它时,它给出了空响应。
这是我在 Andorid 中的 api 参数:
fun getData(mainActivity: MainActivity): Boolean {
val params = HashMap<String, Any>()
params["phone"] = "+923364451111@c.us"
params["body"] = "Zeeshan Hello, world! "
retrofitClient.abc("01jideaw5zab024y", params).enqueue(object : Callback<Whatsapp> {
override fun onResponse(call: Call<Whatsapp>, response: Response<Whatsapp>) {
Log.d("SoS", "response: " + response.body())
Log.d("SoS", "response: " + response.body()?.sent)
}
override fun onFailure(call: Call<Whatsapp>, t: Throwable) {
Log.d("SoS", "error: " + t.message)
}
})
}
我使用的端点是这样的:
@POST("/sendMessage")
fun abc(@Query("token") token: String, @Body body: HashMap<String, Any>): Call<Whatsapp>
这是我的 Whatsapp 课程:
class Whatsapp{
@SerializedName("sent")
@Expose
var sent: Boolean? = null
@SerializedName("message")
@Expose
var message: String? = null
@SerializedName("id")
@Expose
var id: String? = null
@SerializedName("queueNumber")
@Expose
var queueNumber: Int? = null
}
我想我没有正确使用参数。任何人都可以在这里帮助我如何使用参数。