kotlin - 改造通过标题和字段获取响应消息
问题描述
我想从我的 API 获取响应消息
这是我的 API.kt
@Headers("Accept: application/json")
@FormUrlEncoded
@POST("attendances/clock-in")
fun employeeClockIn(
@Header("Authorization") token: String?,
@Field("username ") username: String?,
@Field("clock_in_ip_address") clkInIpadd : String?,
@Field("clock_in_latitude") clkInLat : String?,
@Field("clock_in_longitude") clkInLang: String?
): Call<ClockInRes>
这是在我的片段中使用 api 的 post 方法
var responseclkin = RetroFitClient().apiService.employeeClockIn("Bearer $passtoken",full_data?.username,getIpv4HostAddress(),location?.latitude.toString(),location?.longitude.toString())
println("tesklik : Bearer $passtoken ${full_data?.username} ${getIpv4HostAddress()} ${location?.latitude} + ${location?.longitude}")
tapin.setOnClickListener{
//isitapin.text= getCurrentDate()
responseclkin.enqueue(object : Callback<ClockInRes>{
override fun onFailure(call: Call<ClockInRes>, t: Throwable) { Toast.makeText(activity,"Jaringan error, silahkan coba lagi", Toast.LENGTH_SHORT).show() }
override fun onResponse(call: Call<ClockInRes>, response: Response<ClockInRes>) {
isitapin.text=response.body()?.data?.clock_in
Toast.makeText(activity,response.body()?.message , Toast.LENGTH_SHORT).show()
}
})
}
我在邮递员中使用 Header 和 Body 来获得响应,这里是截图 pic1 pic2
我在 Toast 上收到空白消息
解决方案
推荐阅读
- docker - Docker 1.6.2:“系统错误:没有这样的设备”启动 hello-world 图像时
- java - WiFi MAC地址在关于手机>状态中不可用
- python - Discord.py - 检查用户是否具有执行命令的特定角色
- python-3.x - 用Python分割文件时,Grep命令找不到单词
- ruby-on-rails - 'bash' : 没有这样的文件或目录
- python - 尝试仅从 FTP 文件夹下载特定文件
- apache-nifi - 如何根据Nifi流中的给定年份范围获取每个月的第一个日期
- excel - sumproduct 作为字符串
- git - 在删除本地 Git 存储库之前,请检查是否没有丢失任何内容
- javascript - IE中的隐藏元素导致表单提交