繁体   English   中英

如何使用java从太阳风Orion rest API获取JSON数据

[英]How to get JSON data from solar winds Orion rest API using java

我想从solarwinds orion rest api 获取JSON 数据,并且必须将这些JSON 数据写入excel 文件中。

我假设您需要一个 Java 程序来向 API 端点发送 post 请求。 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
    }
}

取自这个答案

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM