我正在使用升级的android应用程序进行网络通话。这就是我所说的web服务:
CertificatePinner certificatePinner = new CertificatePinner.Builder()
.add(hostName, "sha256/#####################")
.add(hostName, "sha256/#####################")
.add(hostName, "sha256/#####################")
.build();
OkHttpClient okHttpClient = new OkHttpClient.Builder()
.connectTimeout(CONNECTION_TIMEOUT, TimeUnit.MILLISECONDS)
.readTimeout(CONNECTION_TIMEOUT, TimeUnit.MILLISECONDS)
.certificatePinner(certificatePinner)
.build();
if (retrofit == null) {
retrofit = new Retrofit.Builder()
.baseUrl(BASE_URL)
.client(okHttpClient)
.addConverterFactory(GsonConverterFactory.create())
.build();
}
return retrofit;在服务调用之后,我将在onResponse()方法中获得以下消息:
Response{protocol=http/1.1, code=404, message=Not Found, url=https://hostname/myServiceMethod?Type=xyz?roundtrip=true}下面是我的接口代码:
@Headers({"Accept:application/xyz-v1.0+json"})
@GET("/methodName/{id}/abc?type=ABC")
Call<JsonElement> getServerData(@HeaderMap Map<String, String> headers, @Path("id") String id);在URL末尾添加?roundtrip=true的改进。正因为如此,我得到了404的代码,没有找到。有人能解释一下为什么会这样吗?以及如何删除这个?roundtrip=true?
发布于 2019-06-14 09:51:00
我不认为改造是原因。我建议您使用一些记录器/拦截器,在被截获的请求中添加"?roundtrip=true“查询。我曾经遇到过类似的问题,通过在LoggingInterceptor中添加查询参数来意外地。我建议搜索“往返”用法的项目源代码:
如果您正在使用Android / Intellij :右键单击模块/包>查找路径>“往返”
我想其中一个搜索结果会回答你的问题-它是从哪里来的。
https://stackoverflow.com/questions/56592481
复制相似问题