3 回答

TA貢獻1827條經(jīng)驗 獲得超8個贊
好吧,經(jīng)過一段時間后,我發(fā)現(xiàn)客戶端上缺少一個標頭。
我是這樣添加的
@Headers("Accept: application/json") @GET("myurl")
這解決了問題

TA貢獻1794條經(jīng)驗 獲得超8個贊
在 kotlin 中使用以下代碼轉(zhuǎn)換器進行 Void 響應(yīng)。由于沒有官方支持取消 Retrofit 的響應(yīng)。
? ? object UnitConverterFactory : Converter.Factory() {
? override fun responseBodyConverter(type: Type, annotations: Array<out Annotation>,
? ? ? retrofit: Retrofit): Converter<ResponseBody, *>? {
? ? return if (type == Unit::class.java) UnitConverter else null
? }
? private object UnitConverter : Converter<ResponseBody, Unit> {
? ? override fun convert(value: ResponseBody) {
? ? ? value.close()
? ? }
? }
}

TA貢獻1963條經(jīng)驗 獲得超6個贊
我懷疑 / 在細節(jié)之后是問題所在。請在詳細信息后刪除 /@GET("{department}/details/")
并重新啟動您的應(yīng)用程序它會工作。它給出 400,因為在請求中你沒有傳遞額外的/之后的細節(jié)。https://my-url/departmentId/details (272ms, unknown-length body)
添加回答
舉報