【发布时间】:2018-12-24 02:07:25
【问题描述】:
我需要发送一个带有 GET 请求的正文,但得到了:"Exception : lateinit property sourceCallback has not been initialized". 我在 kotlin 1.3.10 中使用 Fuel 和 Android Studio。
有其他选择吗?
我遵循你的职责,
private fun getReq (json : JSONObject) {
thread {
FuelManager.instance.basePath = "https://blih.epitech.eu"
Fuel.upload("/repositories", Method.GET)
.body(json.toString().toByteArray())
.header("Content-Type" to "application/json")
.response { request, response, result ->
val (bytes, error) = result
if (bytes != null) {
println("[response bytes] ${String(bytes)}")
}
println(error)
}
}
Thread.sleep(1000)
}
更新:
我添加了.source { _, _ -> File.createTempFile("temp", ".tmp")},并且 sourceCallback 不再有问题,但现在得到“异常:方法不支持请求正文:GET”。有什么解决办法吗?
【问题讨论】: