android - 使用 Retrofit Get 方法的动态端点
问题描述
这是我的请求网址: http : //getpincodes.info/api.php?pincode=560054 其中 pincode 值是动态的。
这是我的代码:
public interface PincodeDetailsService
@GET("")
Call<PincodeDetailsResponse> getPin(@Url String url);
}
apiUtils:
公共静态最终字符串 PINCODE_URL ="http://getpincodes.info/";
public static PincodeDetailsService getPincodeDetailsService() {
return RetrofitClientInstance.getRetrofitInstance(PINCODE_URL).create(PincodeDetailsService.class);
}
在进行网络通话时如何通过另一部分?有人可以帮我吗?
解决方案
签名应该是这样的:
@GET("api.php")
Call<PincodeDetailsResponse> getPin(@Query("pincode") int pincode);
然后简单地调用它使用
getPin(560054);
推荐阅读
- javascript - 使用画布压缩图像不适用于移动设备
- javascript - 出于可访问性目的,内部导航栏选项卡是否被视为链接或按钮,它们需要哪些伪状态?
- mysql - 将行插入到参与约束相互限制的表中
- html - 如何使用输入元素设置按钮+垂直中心?
- java - Android SDK:如何生成和导出包含 ArrayList 数据的 excel 文件
- image - 如何使用 MATLAB 图像处理计算锥形喷雾图像(2D)的半长面积?
- bash - 使用 awk 格式化动态数据
- android - Google 登录不适用于受信任的 Web 活动 (TWA) 发行版 apk,但适用于调试 apk
- java - Spring JMS 消息侦听器找不到 JNDI 查找
- angular - 我想使用 Angular 实现 datePicker,但日历显示不正确