Reputation: 5469
I'm switching to the new Request/Response implementation provied by OkHttp 2.0
I got no problem with GET request, I can easily read the response body string, instead I have a problem reading response body string from POST request.
Actually I make a POST request (request body is a JSON media type) to my server that is responding with 201 http status code and a JSON inside the response body.
The POST request go fine (server is saving data) but I cannot read the body string from my android app. The response body string is an empty string while the response http status code is correctly 201.
I'm reading the response body like in the GET request with response.body().string(). Should I do something particular on client/server side to read correctly the response body string?
Upvotes: 0
Views: 1468
Reputation: 5469
It seems that the problem was server side.
When I specified from server side that the response content_type was "application/json" and status=200 (I was using 201) the response.body().string() from OkHttp returned the real response JSON instead of the empty string.
Upvotes: 0