Any Idea how can I change the id subdirectory to a variable that will takes the value of the function argument? The id query is incorrect since it's gonna be after information.
@GET("recipes/id/information")
suspend fun getRecipeInformation(
@Query("id")
id: Int,
@Query("apiKey")
apiKey: String) : Response<RecipesByIngredientsResponse>
CodePudding user response:
If my understanding is correct, you have to define the id argument as a Path variable, instead of Query:
@GET("recipes/{id}/information")
suspend fun getRecipeInformation(
@Path("id")
id: Int,
@Query("apiKey")
apiKey: String) : Response<RecipesByIngredientsResponse>
Notice the syntax:
- the id is in curly braces
- Path annotation is used instead of Query
Official documentation: Path