0

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);

1 Answers1

0

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

warren
  • 32,620
  • 21
  • 85
  • 124