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
Can you try:
ServiceArgs loginArgs = new ServiceArgs();
loginArgs.setUsername("username");
loginArgs.setPassword("password");
loginArgs.setHost(host);
loginArgs.setPort(Integer.parseInt(port));
Service.connect(loginArgs);