<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: (401 Unauthorized Exception)Unable to send query using java SDK in Splunk Dev</title>
    <link>https://community.splunk.com/t5/Splunk-Dev/401-Unauthorized-Exception-Unable-to-send-query-using-java-SDK/m-p/108613#M1611</link>
    <description>&lt;P&gt;Are the 401 errors interleaved with successful requests , or do they only start occurring after a period of time ?&lt;/P&gt;</description>
    <pubDate>Mon, 29 Jul 2013 09:06:11 GMT</pubDate>
    <dc:creator>Damien_Dallimor</dc:creator>
    <dc:date>2013-07-29T09:06:11Z</dc:date>
    <item>
      <title>(401 Unauthorized Exception)Unable to send query using java SDK</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/401-Unauthorized-Exception-Unable-to-send-query-using-java-SDK/m-p/108612#M1610</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;
I am connecting splunk with java sdk and trying to send a query. Its getting connected but when i am trying to send a query it behaves weirdly .Some time it gives the result but some times it gives com.splunk.HttpException: HTTP 401 -- call not properly authenticated. &lt;BR /&gt;
The same query executes  fine but most of the time it gives the above exception. I am unable to proceed further due to the above issue. Kindly help me out. Please find the below code.&lt;BR /&gt;
ServiceArgs loginArgs = new ServiceArgs();&lt;BR /&gt;
        loginArgs.setUsername("username");&lt;BR /&gt;
        loginArgs.setPassword("password");&lt;BR /&gt;
        loginArgs.setHost("hostname");&lt;BR /&gt;
        loginArgs.setPort(8089); &lt;BR /&gt;
        Service service = Service.connect(loginArgs);&lt;BR /&gt;
        System.out.println("Connected");&lt;BR /&gt;
String searchQuery_normal ="search index=app sourcetype=tomcat_access host=\"cglita*\" (source=\"/var/opt/tomcat/logs/saelHDcomNavAndSearchWebService/access.log\" OR source=\"/var/opt/tomcat/logs/saelHDcomProductDataWebService/access.log\" OR source=\"/var/opt/tomcat/logs/saelOnlineStoreFinder/access.log\") uri!=\"&lt;EM&gt;Probe&lt;/EM&gt;\"| timechart count as \"Pageviews\", avg(response_time) as \"Response Time\" by source | tail 5 ";&lt;BR /&gt;
            JobArgs jobargs = new JobArgs();&lt;BR /&gt;
            jobargs.setExecutionMode(JobArgs.ExecutionMode.NORMAL);&lt;BR /&gt;
            jobargs.setEarliestTime("-15m@m");&lt;BR /&gt;
            jobargs.setLatestTime("now");&lt;BR /&gt;
            Job job = service.getJobs().create(searchQuery_normal,jobargs);&lt;BR /&gt;
            JobResultsArgs resultsArgs = new JobResultsArgs();&lt;BR /&gt;
            resultsArgs.setOutputMode(JobResultsArgs.OutputMode.XML);&lt;BR /&gt;
            InputStream results = job.getResults(resultsArgs);&lt;BR /&gt;
            ResultsReaderXml resultsReader=new ResultsReaderXml(results);&lt;BR /&gt;
            //ResultsReaderCsv resultsReader=new ResultsReaderCsv(results);&lt;BR /&gt;
            //ResultsReaderJson resultsReader = new ResultsReaderJson(results);&lt;BR /&gt;
            HashMap&lt;STRING&gt; event;&lt;BR /&gt;
            System.out.println("\nFormatted results from the search job as CSV\n");&lt;BR /&gt;
            while ((event = resultsReader.getNextEvent()) != null) {&lt;BR /&gt;
                for (String key: event.keySet())&lt;BR /&gt;
                    System.out.println("   " + key + ":  " + event.get(key));&lt;BR /&gt;
            }&lt;BR /&gt;
            resultsReader.close();&lt;BR /&gt;
        } catch (Exception e) {&lt;BR /&gt;
            e.printStackTrace();&lt;/STRING&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;    }
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 28 Sep 2020 14:26:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/401-Unauthorized-Exception-Unable-to-send-query-using-java-SDK/m-p/108612#M1610</guid>
      <dc:creator>madhuinfy</dc:creator>
      <dc:date>2020-09-28T14:26:50Z</dc:date>
    </item>
    <item>
      <title>Re: (401 Unauthorized Exception)Unable to send query using java SDK</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/401-Unauthorized-Exception-Unable-to-send-query-using-java-SDK/m-p/108613#M1611</link>
      <description>&lt;P&gt;Are the 401 errors interleaved with successful requests , or do they only start occurring after a period of time ?&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jul 2013 09:06:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/401-Unauthorized-Exception-Unable-to-send-query-using-java-SDK/m-p/108613#M1611</guid>
      <dc:creator>Damien_Dallimor</dc:creator>
      <dc:date>2013-07-29T09:06:11Z</dc:date>
    </item>
    <item>
      <title>Re: (401 Unauthorized Exception)Unable to send query using java SDK</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/401-Unauthorized-Exception-Unable-to-send-query-using-java-SDK/m-p/108614#M1612</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;
Most of the time they only start occurring after a period of time, but some times it will through in the beginning of the execution only.&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jul 2013 09:35:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/401-Unauthorized-Exception-Unable-to-send-query-using-java-SDK/m-p/108614#M1612</guid>
      <dc:creator>madhuinfy</dc:creator>
      <dc:date>2013-07-29T09:35:05Z</dc:date>
    </item>
    <item>
      <title>Re: (401 Unauthorized Exception)Unable to send query using java SDK</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/401-Unauthorized-Exception-Unable-to-send-query-using-java-SDK/m-p/108615#M1613</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;
Most of the time they only start occurring after a period of time, but some times it will through in the beginning of the execution only&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jul 2013 09:35:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/401-Unauthorized-Exception-Unable-to-send-query-using-java-SDK/m-p/108615#M1613</guid>
      <dc:creator>madhuinfy</dc:creator>
      <dc:date>2013-07-29T09:35:29Z</dc:date>
    </item>
    <item>
      <title>Re: (401 Unauthorized Exception)Unable to send query using java SDK</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/401-Unauthorized-Exception-Unable-to-send-query-using-java-SDK/m-p/108616#M1614</link>
      <description>&lt;P&gt;what is the sessionTimeout value in server.conf&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jul 2013 09:44:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/401-Unauthorized-Exception-Unable-to-send-query-using-java-SDK/m-p/108616#M1614</guid>
      <dc:creator>Damien_Dallimor</dc:creator>
      <dc:date>2013-07-29T09:44:31Z</dc:date>
    </item>
    <item>
      <title>Re: (401 Unauthorized Exception)Unable to send query using java SDK</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/401-Unauthorized-Exception-Unable-to-send-query-using-java-SDK/m-p/108617#M1615</link>
      <description>&lt;P&gt;splunk server is located in a remote system so i cannot see the details of server.conf. but if i login to splunk app directly and execute the query , it executes as many times as i want with out any issue. I guess there is no problem with the session time out else i would get the same error when i run the query with splunk web.&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jul 2013 11:52:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/401-Unauthorized-Exception-Unable-to-send-query-using-java-SDK/m-p/108617#M1615</guid>
      <dc:creator>madhuinfy</dc:creator>
      <dc:date>2013-07-29T11:52:12Z</dc:date>
    </item>
    <item>
      <title>Re: (401 Unauthorized Exception)Unable to send query using java SDK</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/401-Unauthorized-Exception-Unable-to-send-query-using-java-SDK/m-p/108618#M1616</link>
      <description>&lt;P&gt;Is there anything on the network between your java client and splunkd that could be affecting the authentication token in the HTTP header ?Or anything in you code ?&lt;/P&gt;

&lt;P&gt;How are you using your Service object in your code ? Singleton ?&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jul 2013 14:32:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/401-Unauthorized-Exception-Unable-to-send-query-using-java-SDK/m-p/108618#M1616</guid>
      <dc:creator>Damien_Dallimor</dc:creator>
      <dc:date>2013-07-29T14:32:57Z</dc:date>
    </item>
    <item>
      <title>Re: (401 Unauthorized Exception)Unable to send query using java SDK</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/401-Unauthorized-Exception-Unable-to-send-query-using-java-SDK/m-p/108619#M1617</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;
There is nothing between splunkd and java client. I am just using my ldap id and password to connect to splunk. No service object is not a singleton in my code.&lt;/P&gt;</description>
      <pubDate>Tue, 30 Jul 2013 05:31:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/401-Unauthorized-Exception-Unable-to-send-query-using-java-SDK/m-p/108619#M1617</guid>
      <dc:creator>madhuinfy</dc:creator>
      <dc:date>2013-07-30T05:31:36Z</dc:date>
    </item>
  </channel>
</rss>

