Reputation: 13329
I'm getting the response like this:
HttpResponse response = httpclient.execute(httpget);
response.getStatusLine().toString());
In this case the response is:
HTTP/1.1 500 invalid user credentials
Ho do I get the message only, without the code?
**invalid user credentials**
Upvotes: 0
Views: 1543
Reputation: 967
Use getReasonPhrase() method of StatusLine interface. e.g.
HttpResponse response = httpclient.execute(httpget);
StatusLine statusLine = response.getStatusLine();
statusLine.getReasonPhrase()
Upvotes: 0
Reputation: 6197
Simple, do this
String responseStr = EntityUtils.toString(response.getEntity());
This will work!
Upvotes: 1
Reputation: 1328
Try this:
HttpResponse response = httpclient.execute(httpget);
StatusLine statusLine = response.getStatusLine();
String messageOnly = statusLine.getReasonPhrase();
int codeOnly = statusLine.getStatusCode();
Upvotes: 1
Reputation: 2885
try this :
HttpResponse response = client.execute(httpGet);
HttpEntity entity = response.getEntity();
InputStream content = entity.getContent();
and then convert this input stream into string......
Upvotes: 0
Reputation: 3756
You could simply get the message like this
String message = response.getStatusLine().toString().substring(12);
Upvotes: 0