我想从 solarwinds orion rest api 获取 JSON 数据,并且必须将这些 JSON 数据写入 excel 文件。
问问题
133 次
1 回答
0
我假设您需要一个 java 程序来向 API 端点发送一个发布请求。ApacheHTTP 库来救援。您可以从此处的文档中阅读更多信息。更多信息在官方 apache 网站
HttpClient httpclient = HttpClients.createDefault();
HttpPost httppost = new HttpPost("http://www.a-domain.com/foo/");
// Request parameters and other properties.
List<NameValuePair> params = new ArrayList<NameValuePair>(2);
params.add(new BasicNameValuePair("param-1", "12345"));
params.add(new BasicNameValuePair("param-2", "Hello!"));
httppost.setEntity(new UrlEncodedFormEntity(params, "UTF-8"));
//Execute and get the response.
HttpResponse response = httpclient.execute(httppost);
HttpEntity entity = response.getEntity();
if (entity != null) {
try (InputStream instream = entity.getContent()) {
// do something useful
}
}
取自这个答案
于 2020-02-28T07:42:21.160 回答