How is a POST with parameters accomplished using the Google HTTP Java client library?
This does not work:
public void run() throws Exception {
HttpRequestFactory requestFactory
= new NetHttpTransport().createRequestFactory();
//String params = "{'userid': 'me', 'password': 'mk8e!'}";
String params = "{\"userid\": \"me\", \"password\": \"mk8e!\"}";
HttpContent content = ByteArrayContent.fromString("application/json", params);
GenericUrl url = new GenericUrl(myPostURL);
HttpRequest request = requestFactory.buildPostRequest(url, content);
HttpResponse response = request.execute();
}
I get a message back from the server:
Bad request. Parameter userid not found. Parameter password not found
at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:1113)
google-http-java-client