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
Get Updates on the Splunk Community!

Stay Connected: Your Guide to May Tech Talks, Office Hours, and Webinars!

Take a look below to explore our upcoming Community Office Hours, Tech Talks, and Webinars this month. This ...

They're back! Join the SplunkTrust and MVP at .conf24

With our highly anticipated annual conference, .conf, comes the fez-wearers you can trust! The SplunkTrust, as ...

Enterprise Security Content Update (ESCU) | New Releases

Last month, the Splunk Threat Research Team had two releases of new security content via the Enterprise ...