{
HttpClient httpclient = new HttpClient();
int rCode = httpclient.executeMethod(postmethod);
if(rCode == 204)
{
return "204 returned. No content returned, post was successful";
}
String returnData = readInputStreamResponse(postmethod.getResponseBodyAsStream());
if(rCode != 200)
{
String msg = "A non 200 code was returned from the google server. Return code is :" + rCode + " full response " + returnData;
if(rCode == 400 && returnData.contains("invalid_grant"))
{
throw new InvalidGrantException(msg);
}
throw new Exception(msg);
}
if(returnData == null || returnData.contains(GoogleConstants.ERROR))
{
throw new Exception("Errors in executing post :" + returnData);
}
return returnData;
}