I\'m using Retrofit to make a POST Request in my web server.
However, I can\'t seem to get the response body when the response status is 422 (unprocessable entit
I got the same error. My API was working using POSTMAN request but not working from Android retrofit call.
At first I was trying using @Field but it was getting error but later I've tried with @Body and it worked.
Sample Retrofit interface call
@POST("api/v1/app/instance")
Call updateTokenValue(
@HeaderMap Map headers,
@Body String body);
and API calling code is:
Map headerMap=new HashMap<>();
headerMap.put("Accept", "application/json");
headerMap.put("Content-Type", "application/json");
headerMap.put("X-Authorization","access_token");
Map fields = new HashMap<>();
fields.put("app_name", "video");
fields.put("app_version", "2.0.0");
fields.put("firebase_token", "token");
fields.put("primary", "1");
ApiInterface apiInterface = ApiClient.getApiClient().create(ApiInterface.class);
Call call = apiInterface.updateTokenValue(
headerMap,new Gson().toJson(fields));