任何想法如何將 id 子目錄更改為將采用函式引數值的變數?id 查詢不正確,因為它會在資訊之后。
@GET("recipes/id/information")
suspend fun getRecipeInformation(
@Query("id")
id: Int,
@Query("apiKey")
apiKey: String) : Response<RecipesByIngredientsResponse>
uj5u.com熱心網友回復:
如果我的理解是正確的,您必須將id引數定義為Path變數,而不是Query:
@GET("recipes/{id}/information")
suspend fun getRecipeInformation(
@Path("id")
id: Int,
@Query("apiKey")
apiKey: String) : Response<RecipesByIngredientsResponse>
注意語法:
- 該ID是在大括號
- 使用路徑注釋代替Query
官方檔案:路徑
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/372086.html
