改造2-POST请求变为GET?

Rya*_*anB 5 android retrofit2

我的POST请求不断发送GET并被API端点拒绝

MyService类

@FormUrlEncoded
@POST("api/users/")
Call<List<User>> getUsers(@FieldMap HashMap<String, String> parameters);
Run Code Online (Sandbox Code Playgroud)

请求代码

Gson builder = new GsonBuilder().setLenient().create();
Retrofit client = new Retrofit.Builder()
        .baseUrl(Constants.API_ENDPOINT_TEST_URL)
        .addConverterFactory(GsonConverterFactory.create(builder))
        .build();
mApiService = client.create(MyService.class);
Call<List<User>> call = mApiService.getUsers(mParameters);
call.enqueue(new Callback<List<User>>() {
    @Override
    public void onResponse(Call<List<User>> call, Response<List<User>> response) {
        mResponse = response.body();
        mResponseObserver.onFinish(mResponse);
    }

    @Override
    public void onFailure(Call<List<User>> call, Throwable t) {
        mResponseObserver.onFailure();
    }
});
Run Code Online (Sandbox Code Playgroud)

但是服务器拒绝了它,因为它以GET请求形式到达了服务器!与调试器检查后,我看到了:

rawResponse.request.method = GET

这是监视窗口的屏幕截图,显示了改造的请求对象:

屏幕截图

如您所见,请求方法为GET。但是奇怪的部分在中tag,它显示带有POST方法的请求对象?

我在这里想念什么吗?

更新

我添加了日志拦截器,这是日志:

D/OkHttp: --> POST http://***/api/users/ http/1.1
D/OkHttp: Content-Type: application/x-www-form-urlencoded
D/OkHttp: Content-Length: 56
D/OkHttp: --> END POST
D/OkHttp: <-- 200 OK https://***/api/users/ (388ms)
D/OkHttp: Date: Thu, 01 Sep 2016 11:50:23 GMT
D/OkHttp: Server: Apache
D/OkHttp: X-Powered-By: PHP/5.4.34
D/OkHttp: Cache-Control: max-age=2592000
D/OkHttp: Expires: Sat, 01 Oct 2016 11:50:23 GMT
D/OkHttp: Vary: Accept-Encoding
D/OkHttp: Content-Type: application/json; charset=UTF-8
D/OkHttp: Set-Cookie: SESSION_DEFAULT=***; expires=Sun, 04-Sep-2016 11:50:24 GMT; path=/; HttpOnly
D/OkHttp: Set-Cookie: COOKIE[***]=***; path=/; httponly
D/OkHttp: Connection: close
D/OkHttp: <-- END HTTP
Run Code Online (Sandbox Code Playgroud)

看起来要求是POST。但是,服务器仍然会返回错误消息,表示请求方法是GET

嗯,我会再深入一点。

Rya*_*anB 5

实际上,问题是两个因素的组合:

  1. 提出了错误的请求协议(http代替https)
  2. 服务器在错误的协议上回应了一条奇怪的消息:“不支持GET”。

当然,感谢@nshmura的协助。