@POST("oauth/request/")
Call<TokenResponse> getTokenAccess(@Body TokenRequest tokenRequest);
public static Retrofit getClient() throws IOException {
HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
OkHttpClient client = new OkHttpClient.Builder().addInterceptor(interceptor).build();
if (retrofit == null) {
retrofit = new Retrofit.Builder()
.baseUrl(BASE_URL)
.client(client)
.addConverterFactory(GsonConverterFactory.create())
.build();
}
return retrofit;
}
08-25 19:30:56.921 15712-15782/my.app.com D/OkHttp: --> POST https://mydomain.com/api/oauth/request/ http/1.1
08-25 19:30:56.921 15712-15782/my.app.com D/OkHttp: Content-Type: application/json; charset=UTF-8
08-25 19:30:56.921 15712-15782/my.app.com D/OkHttp: Content-Length: 165
08-25 19:30:56.921 15712-15782/my.app.com D/OkHttp: {"client_id":"some_client_id","client_secret":"secret","grant_type":"password","password":"password","username":"username"}
08-25 19:30:56.921 15712-15782/my.app.com D/OkHttp: --> END POST (165-byte body)
[2016-08-25 14:01:09] production.INFO: GET https://mydomain.com https://mydomain.com/api/oauth/request https://mydomain.com/api/oauth/request api/oauth/requ
If the OkHttp logging interceptor thinks it's a POST then that means Retrofit sent it as a POST and it's not a problem with this library.
Perhaps your server is responding with a 302 or 303 which OkHttp will follow and change the request method to GET. Your server should respond with 307 if you want the request method to remain unchanged.
Access Token: success Date: Thu, 25 Aug 2016 14:53:02 GMT
Server: Apache/2.4.18
X-Powered-By: PHP/5.6.21
Allow: POST
Cache-Control: no-cache
Vary: Accept-Encoding,User-Agent
Keep-Alive: timeout=5
Connection: Keep-Alive
Content-Type: application/json
08-25 20:23:01.796 11571-11571/com.status.callie D/token聽genration: Access Token: body Response{protocol=http/1.1, code=405, message=Method Not Allowed, url
server responds with 405 method not allowed
Solved, It was because trailing / at the end of url, thanks.