<?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: Why is the Powershell REST API timing out? in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Why-is-the-Powershell-REST-API-timing-out/m-p/378502#M68456</link>
    <description>&lt;P&gt;Aside from changing the credential from file based to prompt based, the script worked fine for me against my remote instance.    Of course my data set from your search was very small and therefore conditions were not present for timeout based on delay in processing large amounts of data synchronously.  I've never had to write an asynchronous query before, but &lt;A href="https://github.com/dstaulcu/SplunkTools/blob/master/GetSearchResultsAsync.ps1"&gt;here&lt;/A&gt; is v1 of my first powershell script to do so.  Let me know if that helps with your situation.&lt;/P&gt;</description>
    <pubDate>Fri, 10 May 2019 02:58:06 GMT</pubDate>
    <dc:creator>dstaulcu</dc:creator>
    <dc:date>2019-05-10T02:58:06Z</dc:date>
    <item>
      <title>Why is the Powershell REST API timing out?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Why-is-the-Powershell-REST-API-timing-out/m-p/378499#M68453</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;

&lt;P&gt;I've made a script in PowerShell which utilizes the REST API input that I have. This script is for downloading extremely large amounts of data from Splunk.&lt;/P&gt;

&lt;P&gt;The problem that I am having is that Invoke-WebRequest is timing out and I cannot get the query to complete. The query stays connected for ~5minutes and times out.&lt;/P&gt;

&lt;P&gt;Code:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[System.Net.ServicePointManager]::ServerCertificateValidationCallback = { $true }
[System.Net.ServicePointManager]::MaxServicePointIdleTime = 5000000
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$User = "admin"
$File = "C:\Temp\Password.txt"
$MyCredential=New-Object -TypeName System.Management.Automation.PSCredential `
 -ArgumentList $User, (Get-Content $File | ConvertTo-SecureString)
$server = 'SPLUNKSERVER'
$url = "https://${server}:8089/services/search/jobs/export"
$search = "search index=_internal earliest=-5m@m | stats count by sourcetype"
$body = @{
    search = $search
    output_mode = "csv"
    earliest_time = "-5m"
    latest_time = "now"
}
Invoke-WebRequest -Method Post -Uri $url -Timeout 3600 -Credential $MyCredential -Body $body | Set-Content C:\Users\User1\Desktop\test.csv
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 01 May 2018 14:57:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Why-is-the-Powershell-REST-API-timing-out/m-p/378499#M68453</guid>
      <dc:creator>abbam</dc:creator>
      <dc:date>2018-05-01T14:57:01Z</dc:date>
    </item>
    <item>
      <title>Re: Why is the Powershell REST API timing out?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Why-is-the-Powershell-REST-API-timing-out/m-p/378500#M68454</link>
      <description>&lt;P&gt;Can you check the script running server to url server has communication.&lt;/P&gt;

&lt;P&gt;Use Ping and telnet.&lt;/P&gt;</description>
      <pubDate>Thu, 03 May 2018 09:31:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Why-is-the-Powershell-REST-API-timing-out/m-p/378500#M68454</guid>
      <dc:creator>ansif</dc:creator>
      <dc:date>2018-05-03T09:31:39Z</dc:date>
    </item>
    <item>
      <title>Re: Why is the Powershell REST API timing out?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Why-is-the-Powershell-REST-API-timing-out/m-p/378501#M68455</link>
      <description>&lt;P&gt;This does not appear to be an answer.   I have the same issue.  Anyone have any thoughts?&lt;/P&gt;</description>
      <pubDate>Thu, 09 May 2019 19:02:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Why-is-the-Powershell-REST-API-timing-out/m-p/378501#M68455</guid>
      <dc:creator>pmccomb001</dc:creator>
      <dc:date>2019-05-09T19:02:18Z</dc:date>
    </item>
    <item>
      <title>Re: Why is the Powershell REST API timing out?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Why-is-the-Powershell-REST-API-timing-out/m-p/378502#M68456</link>
      <description>&lt;P&gt;Aside from changing the credential from file based to prompt based, the script worked fine for me against my remote instance.    Of course my data set from your search was very small and therefore conditions were not present for timeout based on delay in processing large amounts of data synchronously.  I've never had to write an asynchronous query before, but &lt;A href="https://github.com/dstaulcu/SplunkTools/blob/master/GetSearchResultsAsync.ps1"&gt;here&lt;/A&gt; is v1 of my first powershell script to do so.  Let me know if that helps with your situation.&lt;/P&gt;</description>
      <pubDate>Fri, 10 May 2019 02:58:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Why-is-the-Powershell-REST-API-timing-out/m-p/378502#M68456</guid>
      <dc:creator>dstaulcu</dc:creator>
      <dc:date>2019-05-10T02:58:06Z</dc:date>
    </item>
  </channel>
</rss>

