Retrofit Request on IP Address with Port(带端口的IP地址的改装请求)
问题描述
我正在使用Retrofit分析数据。因为我过去常常为Retrofit请求提供基本URL和终结点,所以我不知道如何将IP地址指定为基本URL。
我想使用如下URL:http://xxx.xxx.xx.xxx:xxxx/
是否有任何建议如何设置我的基本URL和端点?
推荐答案
我在改造2中使用的内容如下。
URL_BASE=http://192.168.1.11:8080
Retrofit retrofit = new Retrofit.Builder()
.client(httpClient)
.baseUrl(URL_BASE + "/")
.addConverterFactory(GsonConverterFactory.create())
.build();
终点:http://192.168.1.11:8080/users
@GET("users")
Call<Response> getUser();
这篇关于带端口的IP地址的改装请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!