I need to send JSON data from Jenkins pipeline to Splunk. I am able to make JSON data. I am referring How do I send JSON files to Splunk Enterprise from JAVA? this link. I am getting an error when line no. 5: httppost.setEntity(new StringEntity(eventStr); has been called. please help...
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);
I'm gonna wager your error message says something like " unexpected token at <character count> on <line number>
"
You are missing some close parenthesis (before the semicolon) on line 5, and seem to need some semicolons on lines 2 & 4
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.