【发布时间】:2021-12-20 00:30:00
【问题描述】:
我必须执行以下 API 调用
网址https://devipapi.octavehi.com/api/state/select-list-items?countryId=236
我创建的改造函数是
@GET("country/state/select-list-items?")
suspend fun fetchStates(@Query("countryId") id: Int): Response<List<ServerState>>
但是我从改造中返回了这个 URL
https://devipapi.octavehi.com/api/country/state/select-list-items?&countryId=236
安培 (&) 与 ? 一起附加
如何解决这个问题?
【问题讨论】:
-
删除
?。它假定一个没有 查询字符串 的 URL,它是?...=...&...=...&...=...形式的参数列表。由于 URL 已包含问号,因此在参数前需要一个 & 号。
标签: android retrofit retrofit2