<?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: Converting Splunk Curl API to Windows Powershell in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Converting-Splunk-Curl-API-to-Windows-Powershell/m-p/679062#M232139</link>
    <description>&lt;P&gt;What error do you get from PowerShell?&lt;/P&gt;&lt;P&gt;I see curl uses the -k option, but PowerShell does not use the equivalent -SkipCertificateCheck option.&amp;nbsp; Perhaps that is a factor.&lt;/P&gt;</description>
    <pubDate>Wed, 28 Feb 2024 21:27:08 GMT</pubDate>
    <dc:creator>richgalloway</dc:creator>
    <dc:date>2024-02-28T21:27:08Z</dc:date>
    <item>
      <title>Converting Splunk Curl API to Windows Powershell</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Converting-Splunk-Curl-API-to-Windows-Powershell/m-p/679056#M232135</link>
      <description>&lt;P&gt;I have a working script that allows me to retrieve the job ID of a search in Splunk.&amp;nbsp; This is working in Windows using GNU curl (and is also working --- albeit modified --- in the native Ubuntu Linux version of curl).&lt;/P&gt;&lt;P&gt;I am now trying to take this same approach and run it in Windows Powershell --- unfortunately, I have not yet been successful. Here is what I have so far (working curl version is shown first).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;curl.exe -k -H "Authorization: Bearer &amp;lt;MYTOKEN&amp;gt;" https://&amp;lt;MYINSTANCE&amp;gt;.splunkcloud.com:8089/services/search/jobs/ --data-urlencode  search='&amp;lt;MYSEARCH&amp;gt;'

============
============

$headers = @{
    "Authorization" = "Bearer &amp;lt;MYTOKEN&amp;gt;"
}
$body = @{
    "search" = "&amp;lt;MYSEARCH&amp;gt;"
}
$response = Invoke-WebRequest -Uri "https://&amp;lt;MYINSTANCE&amp;gt;.splunkcloud.com:8089/services/search/jobs/" `
    -Method Post `
    -Headers $headers `
    -ContentType "application/x-www-form-urlencoded" `
    -Body $body `&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any guidance is appreciated.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Feb 2024 20:49:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Converting-Splunk-Curl-API-to-Windows-Powershell/m-p/679056#M232135</guid>
      <dc:creator>qcjacobo2577</dc:creator>
      <dc:date>2024-02-28T20:49:42Z</dc:date>
    </item>
    <item>
      <title>Re: Converting Splunk Curl API to Windows Powershell</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Converting-Splunk-Curl-API-to-Windows-Powershell/m-p/679062#M232139</link>
      <description>&lt;P&gt;What error do you get from PowerShell?&lt;/P&gt;&lt;P&gt;I see curl uses the -k option, but PowerShell does not use the equivalent -SkipCertificateCheck option.&amp;nbsp; Perhaps that is a factor.&lt;/P&gt;</description>
      <pubDate>Wed, 28 Feb 2024 21:27:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Converting-Splunk-Curl-API-to-Windows-Powershell/m-p/679062#M232139</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2024-02-28T21:27:08Z</dc:date>
    </item>
    <item>
      <title>Re: Converting Splunk Curl API to Windows Powershell</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Converting-Splunk-Curl-API-to-Windows-Powershell/m-p/679063#M232140</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/213957"&gt;@richgalloway&lt;/a&gt;&amp;nbsp;I thought the same thing as that did generate an error.&amp;nbsp; If I simply remove that line, I get the following error:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Incomplete string token.
    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : IncompleteString&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 28 Feb 2024 21:41:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Converting-Splunk-Curl-API-to-Windows-Powershell/m-p/679063#M232140</guid>
      <dc:creator>qcjacobo2577</dc:creator>
      <dc:date>2024-02-28T21:41:24Z</dc:date>
    </item>
    <item>
      <title>Re: Converting Splunk Curl API to Windows Powershell</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Converting-Splunk-Curl-API-to-Windows-Powershell/m-p/679064#M232141</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/213957"&gt;@richgalloway&lt;/a&gt;&amp;nbsp;Figured it out --- had an extra "`" character at the end.&amp;nbsp; It is working now.&lt;/P&gt;</description>
      <pubDate>Wed, 28 Feb 2024 21:52:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Converting-Splunk-Curl-API-to-Windows-Powershell/m-p/679064#M232141</guid>
      <dc:creator>qcjacobo2577</dc:creator>
      <dc:date>2024-02-28T21:52:41Z</dc:date>
    </item>
  </channel>
</rss>

