gpt4 book ai didi

android - 在 Retrofit URL 中添加更多 @path

转载 作者:行者123 更新时间:2023-11-30 00:30:27 25 4
gpt4 key购买 nike

我需要有关如何在改造请求中使用多个参数“@path”的帮助。我尝试以这种方式使用单个参数“@Path”。

@GET("topics/{id}?userId=58bf87d343c3ccb5793b2e99")
Call<ResponseBody> artikel(@Path("id") String id);

但是我想像这样使用两个参数

API服务类:

@GET("topics/{id}?userId={userId}")
Call<ResponseBody> artikelFeeds(@Path("id") String id, @Path("userId") String userId);

抛出错误“路径不能有替换 block ”这是改造客户端的一部分

Call<ResponseBody> get_artikel;
Retrofit retrofit;
retrofit = new Retrofit.Builder()
.baseUrl(Status.HOST_ARTICLE)
.addConverterFactory(GsonConverterFactory.create())
.client(httpClient)
.build();

ApiService apiService = retrofit.create(ApiService.class);
get_artikel = apiService.artikelFeeds(id,userId);

最佳答案

试试这个,

@GET("topics/{id}")
Call<ResponseBody> artikelFeeds(@Path("id") String id, @Query("userId") String userId);

关于android - 在 Retrofit URL 中添加更多 @path,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44496835/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com