How to send a POST request with JSON data using google api client library for java?

Viewed 9159

I'm trying to send a post request using the google api client library but not able to succeed.

This is the snippet I'm using

UrlEncodedContent urlEncodedContent = new UrlEncodedContent(paramMap);   //paramMap contains email and password keypairs
HttpRequest request = httpRequestFactory.buildPostRequest(new GenericUrl(Constants.PHP_SERVICE_BASE_PATH + mPath) , urlEncodedContent);
String response = request.execute().parseAsString();

I do not get the expected response. I think it is because the post parameters i.e email and password are not being sent in the correct format. I need to send them in JSON.

NOTE : I'm not using the library for a google web service.

2 Answers
Related