Dashboards & Visualizations

How to get session key for Splunk connect

npbala_22
Explorer

While Connect the Splunk Using Service.connect am getting 401 error due authentication getting failed. I have to pass session key or token on login post method header. Am striking with getting session key/token. Can you resolve this by with out using Curl

Code:

Service service = new Service("XX.XXX.X.XXX", YYYY,"http");
service.login("XXXXXX", "YYYYY);

Error:

Exception in thread "main" com.splunk.HttpException: HTTP 401 -- {"status":1}
at com.splunk.HttpException.create(HttpException.java:84)
at com.splunk.HttpService.send(HttpService.java:500)
at com.splunk.Service.send(Service.java:1297)
at com.splunk.HttpService.post(HttpService.java:348)
at com.splunk.Service.login(Service.java:1125)
at com.Practice.SplunkConnection.secureConnection(SplunkConnection.java:132)
at com.Practice.SplunkConnection.main(SplunkConnection.java:79)
Picked up JAVA_TOOL_OPTIONS: -agentlib:jvmhook

Tags (2)
0 Karma

p_gurav
Champion

Can you try:
ServiceArgs loginArgs = new ServiceArgs();
loginArgs.setUsername("username");
loginArgs.setPassword("password");
loginArgs.setHost(host);
loginArgs.setPort(Integer.parseInt(port));
Service.connect(loginArgs);

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Level Up Your .conf25: Splunk Arcade Comes to Boston

With .conf25 right around the corner in Boston, there’s a lot to look forward to — inspiring keynotes, ...

Manual Instrumentation with Splunk Observability Cloud: How to Instrument Frontend ...

Although it might seem daunting, as we’ve seen in this series, manual instrumentation can be straightforward ...

Take Action Automatically on Splunk Alerts with Red Hat Ansible Automation Platform

Ready to make your IT operations smarter and more efficient? Discover how to automate Splunk alerts with Red ...