我遇到了仅返回状态代码而不是任何 json 或 xml 响应的 api 调用问题,我收到 EOFException。
error - End of input at line 1 column 1 path $
**API** - https://lo.convep.liveperson.net/api/account/3083754/chat/request.json?v=1
**Authorization** - LivePerson appKey=*********************
**Strict-Transport-Security** - **********
**Request** - {
"request": {
"LETagContextId": "1",
"LETagSessionId": "XuUhaCCcR7Kk5lWHhNpFxA",
"LETagVisitorId": "EwY2JmZmYzZTA1MDg3ODk2",
"campaignId": "870922132",
"engagementId": "870924032",
"language": "en-US",
"skill": "In App Chat"
}
}
**response code getting - 201 created**
但没有得到任何数据。
请帮助我如何使用改造在android中解决这个问题
private fun requestChatLivePerson(urlChatRequest: String,visitorId: String?,sessionId: String?,contextId: String?,engagementId: String?, campaignId: String?, skillName: String?, language: String?) {
val gson = Gson()
Log.e("UrlChatRequest",""+gson.toJson(requestChatJson(visitorId, sessionId, contextId, engagementId, campaignId, skillName, language)))
var requestChat = service?.requestChatLive(urlChatRequest,requestChatJson(visitorId, sessionId, contextId, engagementId, campaignId, skillName, language)
)
requestChat?.onResponse(object : Callback<ResponseChat> {
override fun onFailure(call: Call<ResponseChat>, t: Throwable) {
Toast.makeText(this@MainActivity, "Error while requesting chat..." + t.message, Toast.LENGTH_LONG)
.show()
}
override fun onResponse(call: Call<ResponseChat>, response: Response<ResponseChat>) {
if (response.isSuccessful) {
var responseBody = response.body()
var headerList = response.headers()
Toast.makeText(this@MainActivity, "Requesting Chat.Please wait for a moment....", Toast.LENGTH_LONG)
.show()
} else {
Toast.makeText(this@MainActivity, "Error while requesting chat...", Toast.LENGTH_LONG).show()
}
}
})
}
接口方式:
@Headers("Authorization: LivePerson appKey=**********************",
"Content-Type: application/json",
"Strict-Transport-Security: ***************")
@POST
fun requestChatLive(@Url url: String, @Body requestJson: RequestChat): Call<ResponseChat>