【发布时间】:2020-05-04 15:54:28
【问题描述】:
我需要将 JSON 数据从 Jenkins 管道发送到 Splunk。我能够制作 JSON 数据。我指的是 How do I send JSON files to Splunk Enterprise from JAVA?这个链接。 行号时出现错误。 5 : httppost.setEntity(new StringEntity(eventStr); 已被调用。 请帮忙...
DefaultHttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("https://<SERVER>:8088/services/collector/event");
httppost.addHeader("Authorization", " Splunk <token id>");
String eventStr = "{sourcetype=_json, index=main, event={ <JSON> }}"
httppost.setEntity(new StringEntity(eventStr);
HttpResponse response = httpclient.execute(httppost);
HttpEntity entity = response.getEntity();
System.out.println("response: " + entity);
【问题讨论】:
-
你刚刚在第 5 行错过了一个右括号
-
通常,错误消息会向您解释问题。只需阅读它们;)
-
我做到了先生..会再试一次
-
我可以要求你吗?如果您可以与您在代码中导入的类共享代码 sn-p stackoverflow.com/users/1276664/daggett