【发布时间】:2021-02-06 12:04:11
【问题描述】:
我正在使用 Retrofit 进行 API 调用。我的 API 是这样的 https://test/update/123456789..
在此 API 中,需要将“123456789”作为值传递。任何人都可以使用 Retrofit 帮助我做到这一点。如何在没有查询的情况下传递这个值。
在此先感谢..:)
fun updatePriceTesting(@Query("device_id") deviceId: String, @Query("appId") appId: String, @Body RequestBody: RequestBody) : Deferred
回应>
【问题讨论】:
-
@GET("/test/update/:id) fun whatever(@Path("id") id: Int)-- 请参阅the Retrofit docs 中的“URL 操作”部分。 -
@CommonsWare 好的,有时间我试试
-
这将是这样的
@GET("/yourUpdatePathThatWillBeAppendedToBaseUrl/{id}) fun update(@Path("id") id: Int)您的请求类型可能是@POST 或@PUT 这取决于您的Api 实现 -
java.lang.NumberFormatException: For input string: "589656966" got this exception
-
@CommonsWare java.lang.IllegalArgumentException:URL 不包含“{id}”。 (参数#1)
标签: android kotlin mvvm retrofit