首页 > 解决方案 > Retorfit 查询参数采用 & 和 ? 一起

问题描述

我必须执行以下 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

安培 (&) 与 ?

如何解决这个问题?

标签: androidretrofitretrofit2

解决方案


消除 '?' 来自@GET

@GET("country/state/select-list-items")
suspend fun fetchStates(@Query("countryId") id: Int): Response<List<ServerState>>

推荐阅读