在改造中进行 api 调用时出现此错误响应{protocol=http/1.1, code=407, message=Proxy Authentication required, url= http://example.com/test.xml }下面是我的 api 调用。 private void showProxies() { serviceCall = apiService.listOfServers(); serviceCall.enqueue(new Callback<ServerListModel>() { @Override public void onResponse(Call<ServerListModel> call, Response<ServerListModel> response) { if (response.body() != null) { ArrayList<Proxies> proxyArrayList = response.body().proxiesArrayList; showProxyDialog(proxyArrayList); } else Toast.makeText(BrowserActivity.this, "Server 407 error.", Toast.LENGTH_SHORT).show(); } @SuppressLint("LongLogTag") @Override public void onFailure(Call<ServerListModel> call, Throwable t) { Log.e(TAG, t.toString()); } });}
1 回答
小怪兽爱吃肉
TA贡献1852条经验 获得超1个赞
你已经为你的 Retrofit 对象添加了代理
java.net.Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(proxyHost, proxyPort));
OkHttpClient client = new OkHttpClient.Builder().proxy(proxy).build();
Retrofit.Builder builder = new Retrofit.Builder().client(client);
Retrofit retrofit = builder.build();
添加回答
举报
0/150
提交
取消