如何解决如何使用Google HttpClient API进行HTTP POST?
如何使用Java的Google HTTP客户端库完成带有参数的POST?
这不起作用:
public void post() throws Exception {
HttpRequestFactory requestFactory
= new NetHttpTransport().createRequestFactory();
String myPostURL = "https://my-post-url"
//String params = "{'userid': 'me','password': 'jt48e!'}";
String params = "{\"userid\": \"me\",\"password\": \"jt48e!\"}";
HttpContent content = ByteArrayContent.fromString("application/json",params);
GenericUrl url = new GenericUrl(myPostURL);
HttpRequest request = requestFactory.buildPostRequest(url,content);
HttpResponse response = request.execute();
}
致电时收到错误消息:
Bad request. Parameter userid not found. Parameter password not found.
at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:1113)
Google HttpClient库Java
google-http-java-client
google-http-client
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。