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!

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...

Introducing Splunk Enterprise 9.2

WATCH HERE! Watch this Tech Talk to learn about the latest features and enhancements shipped in the new Splunk ...

Adoption of RUM and APM at Splunk

    Unleash the power of Splunk Observability   Watch Now In this can't miss Tech Talk! The Splunk Growth ...