我需要发送带有GET请求的正文,但收到:"Exception : lateinit property sourceCallback has not been initialized".
我在 Android Studio 和 kotlin 1.3.10 中使用了Fuel。
是否有其他选择?
我遵循你的职责,
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”。有什么办法吗?
最佳答案
Fuel lib的开发者回答我,它将添加到版本2.0.0中
github answer from Fuel dev
关于android - 使用Fuel向 body 发送GET请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53908540/