Below image is the response of whatsap api which run fine on postman.
But when I try to run it on android project by using retrofit it is giving null response.
Here is my api parameter in Andorid:
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)
}
})
}
And its endpoint I am using like this:
@POST("/sendMessage")
fun abc(@Query("token") token: String, @Body body: HashMap<String, Any>): Call<Whatsapp>
Here is my Whatsapp Class:
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
}
I think I am not using parameters correctly. Anyone help me how to use parameters here.