我想从 Solarwinds Orion Rest api 获取 JSON 数据,并且必须将这些 JSON 数据写入 Excel 文件中。
最佳答案
我假设您需要一个 java 程序来向 API 端点发送 post 请求。 ApacheHTTP 库来救援。您可以从文档 here 中阅读更多内容。更多信息请参见 official apache website
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
}
}
取自 this回答
关于java - 如何使用 java 从太阳风 Orion Rest API 获取 JSON 数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60446771/