I have cross checked a lot of reference before actually asking the question. As most people I am calling a web service and and getting the above result. My problem is rather more specific, so before asking let me add my code snippet
public static WebService getRestService(String newApiBaseUrl, String accessToken)
{
OkHttpClient.Builder httpClient = new OkHttpClient.Builder();
if (BuildConfig.DEBUG) {
HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
logging.setLevel(HttpLoggingInterceptor.Level.BODY);
httpClient.addInterceptor(logging);
}
Gson gson = new GsonBuilder()
.setLenient()
.create();
restBuilder = new Retrofit.Builder()
.baseUrl(newApiBaseUrl)
.client(httpClient.build())
.addConverterFactory(GsonConverterFactory.create(gson));
if (accessToken != null) {
AuthenticationInterceptor interceptor =
new AuthenticationInterceptor(accessToken);
if (!httpClient.interceptors().contains(interceptor)) {
httpClient.addInterceptor(interceptor);
restBuilder.client(httpClient.build());
}
}
retrofit = restBuilder.build();
return retrofit.create(WebService.class);
}
Please ignore the interpreter. This is my service generator class through which all web service is called. I am calling a POST method which will return me a simple response.
I can see my correct response in "Android Monitor". But when its passes through JsonConverterFactory, it gives me above error. One thing I know for sure that web service is returning a simple text response as there is nothing specific to return to application. Is there a way by which I can convert my text response to class. Please free shout back if I missed anything.
Also adding my interface method
@Headers({
Constants.ApiHeader.CONTENT_TYPE_JSON
})
@POST("POST_URL/{number}")
Call<MyResponseModel> getActualProductLocation(@Header("access_token") String accessToken, @Path("number") String number, @Body List<MyRequestModel> body);
Update I managed to get a part of code snippet from server. This is what their response look like:
Response.status(200).entity("Response Success").build()