splunk-sdk-java: splunk sdk : com.splunk.HttpException: HTTP 401 -- call not properly authenticated

I am trying to search the string from splunk , i was getting 401 error. StringBuilder searchString = new StringBuilder();

    searchString.append("search").append(" XXX");

Service service = Service.connect(splunkArgs); Job job = service.getJobs().create(searchString.toString());

About this issue

  • Original URL
  • State: closed
  • Created 10 years ago
  • Comments: 26 (9 by maintainers)

Most upvoted comments

HTTP 401 – {“messages”:[{“type”:“WARN”,“text”:“call not properly authenticated”}]}

We are seeing this error intermittently. From what I can tell, it happens after the request is submitted to the server. I even suspect the query itself is being executed. I suspect this because our Splunk team is reporting more concurrent sessions for our user than is possible for us.

Is it possible the error messes is incorrect? I ask this because we get this once in a while from a process that is running and submits the request in the same way every time.

I was getting the same error. I have fixed this problem by upgrading splunk-sdk-java library from 1.3.2 to 1.6.5 (latest one). Now it’s working fine.

This issue is still present:

ServiceArgs loginArgs = new ServiceArgs(); loginArgs.setUsername(“username”); loginArgs.setPassword(“password”); loginArgs.setHost(host); loginArgs.setPort(Integer.parseInt(port)); Service.connect(loginArgs);

Then, I check if login is successful by having this line of code:

System.out.println("Installed apps: " + service.getApplications().keySet()); I get all apps and then search with JobExportArgs exportArgs = new JobExportArgs();

exportArgs.setEarliestTime(“-5”); exportArgs.setLatestTime(“now”); exportArgs.setRequiredFieldList(“string”); exportArgs.setSearchMode(JobExportArgs.SearchMode.NORMAL);

InputStream exportSearch = service.export(searchQuery, exportArgs);

Call fails at above line (service.export(searchQuery, exportArgs)) - com.splunk.HttpException: HTTP 401 – call not properly authenticated