Quantcast
Channel: Questions in topic: "splunk-enterprise"
Viewing all articles
Browse latest Browse all 47296

Unable to login through Java SDK (400 BAD REQUEST)

$
0
0
Hi there, I am working on a java application for my company that is going to use the splunk java sdk to run some scheduled searched and then perform some other operations with the data that it receives back. I am however, having some issues with successfully managing to log into splunk through the Java SDK, Every time I try I get back a 400 error (BAD REQUEST) saying that the request that I have made to the server is not valid. Here is the exact error that I get in the console from java. [Fatal Error] :1:3: The markup in the document preceding the root element must be well-formed. com.splunk.HttpException: HTTP 400 at com.splunk.HttpException.create(HttpException.java:59) at com.splunk.HttpService.send(HttpService.java:355) at com.splunk.Service.send(Service.java:1211) at com.splunk.HttpService.post(HttpService.java:212) at com.splunk.Service.login(Service.java:1044) at com.splunk.Service.login(Service.java:1024) at stc.classes.LoginController.connectAndLogIntoSplunk(LoginController.java:24) at stc.classes.Main.main(Main.java:11) I have tried to follow a number of different tutorials in order to get this working but none seem to be able to help. I have double checked what I can identify as the common trouble spots: 1. I have verified that I am connecting to the management port and not the web port 2. I have double checked the Splunk Server Name in the Server Settings > General Settings page when you login through the web 3. I have tripple checked my credentials to ensure that they are not the cause of the issue As far as I can tell I am not missing anything important, yet I obviously still doing something incorrectly. Any help that could be offered would be greatly appreciated. here is my main class import com.splunk.Service; public class Main { public static void main(String[] args) { LoginController loginController = new LoginController(); Service splunkService = loginController.connectAndLogIntoSplunk(); System.out.println("Session token: "+splunkService.getToken()); } } Here is my login controller class import java.util.HashMap; import java.util.Map; import com.splunk.Service; public class LoginController { public static Service connectAndLogIntoSplunk(){ //Connection and login arguments Map connectionArgs = new HashMap(); connectionArgs.put("host", "hostname.for.the.splunkd.server"); connectionArgs.put("username", "user.name"); connectionArgs.put("password", "p@55w02d"); connectionArgs.put("port", 8089); connectionArgs.put("scheme", "https"); //attempt connection Service ss = new Service(connectionArgs); try { ss.login(); //THIS IS THE LINE THAT IS CAUSING THE ERROR } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } //return the splunk service return ss; } }

Viewing all articles
Browse latest Browse all 47296

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>