0
我有一个json字符串,我想将它传递给POST方法。但'执行'和'executeMethod'抛出错误如下:将json字符串传递给Post方法
“类型HttpClient中的方法execute(HttpUriRequest)不适用于参数(PostMethod)”。我已经包括了依赖性。
我的代码:
StringRequestEntity requestEntity = new StringRequestEntity(
json-string,
"application/json",
"UTF-8");
PostMethod postMethod = new PostMethod("myUrl");
postMethod.setRequestEntity(requestEntity);
HttpResponse response = httpclient.execute(postMethod);
是否有任何替代办法做到这一点?请帮忙。在此先感谢
与Apache HttpClient也,我得到相同的错误,“该方法执行(HttpPost)是未定义的类型HttpClient” – user3640571