This question may have been asked before but with new version 2.0 I did not find any correct answer yet.
My problem as below:
public interface AuthenticationAPI {
@POST("token")
Call<String> authenticate(@Body String body);
}
Then I call:
Retrofit retrofit = new Retrofit.Builder().baseUrl(authenUrl)
.addConverterFactory(GsonConverterFactory.create())
.build();
AuthenticationAPI authen = retrofit.create(AuthenticationAPI.class);
try {
Call<String> call1 = authen.authenticate(authenBody);
call1.enqueue(new Callback<String>() {
@Override
public void onResponse(Response<String> response, Retrofit retrofit) {
Log.d("THAIPD", "Success " + response.raw().message());
}
@Override
public void onFailure(Throwable t) {
Log.e("THAIPD", " FAIL " + t.getMessage());
}
});
} catch (Exception e) {
Log.e("THAIPD", e.getMessage());
e.printStackTrace();
}
Then I receive the response as protocol=http/1.1, code=400, message=Bad Request
, That means my body parameter was not correct.
When I try to make a request by other tool as Postman I get the correct result with code is 200.
I found this answer but with Retrofit 2.0
I can not find TypedString class.