<?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 REST API to automate CSV creation/export using Python script in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/REST-API-to-automate-CSV-creation-export-using-Python-script/m-p/373900#M67767</link>
    <description>&lt;P&gt;I'm looking to write a Python script modeled after the example on this page: &lt;A href="https://docs.splunk.com/Documentation/SplunkCloud/6.6.0/RESTTUT/RESTsearches"&gt;https://docs.splunk.com/Documentation/SplunkCloud/6.6.0/RESTTUT/RESTsearches&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;However, the example python script only pulls the search ID. When I run the curl command to pull the search ID, then run the curl command to export the results of that search ID, I can't reliably export a CSV.&lt;/P&gt;

&lt;P&gt;Here's the basic curl commands I'm using:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;curl -u user:pass -k &lt;A href="https://splunk.domain.com:8089/services/search/jobs" target="test_blank"&gt;https://splunk.domain.com:8089/services/search/jobs&lt;/A&gt; -d search="search index=my_index | chart count by sourcetype"&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;Then I pull the searchID, for example 1234567.89&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;curl -u user:pass -k &lt;A href="https://splunk.domain.com:8089/services/search/jobs/1234567.89/results" target="test_blank"&gt;https://splunk.domain.com:8089/services/search/jobs/1234567.89/results&lt;/A&gt; --get -d output_mode=csv -o test.csv&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;After this step, if the search job isn't done, then the exported csv will be empty. I've tried to use the python command .sleep(60), but it only works if I'm searching earliest=@min-1min&lt;/P&gt;</description>
    <pubDate>Fri, 18 Aug 2017 17:23:43 GMT</pubDate>
    <dc:creator>jofermin</dc:creator>
    <dc:date>2017-08-18T17:23:43Z</dc:date>
    <item>
      <title>REST API to automate CSV creation/export using Python script</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/REST-API-to-automate-CSV-creation-export-using-Python-script/m-p/373900#M67767</link>
      <description>&lt;P&gt;I'm looking to write a Python script modeled after the example on this page: &lt;A href="https://docs.splunk.com/Documentation/SplunkCloud/6.6.0/RESTTUT/RESTsearches"&gt;https://docs.splunk.com/Documentation/SplunkCloud/6.6.0/RESTTUT/RESTsearches&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;However, the example python script only pulls the search ID. When I run the curl command to pull the search ID, then run the curl command to export the results of that search ID, I can't reliably export a CSV.&lt;/P&gt;

&lt;P&gt;Here's the basic curl commands I'm using:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;curl -u user:pass -k &lt;A href="https://splunk.domain.com:8089/services/search/jobs" target="test_blank"&gt;https://splunk.domain.com:8089/services/search/jobs&lt;/A&gt; -d search="search index=my_index | chart count by sourcetype"&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;Then I pull the searchID, for example 1234567.89&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;curl -u user:pass -k &lt;A href="https://splunk.domain.com:8089/services/search/jobs/1234567.89/results" target="test_blank"&gt;https://splunk.domain.com:8089/services/search/jobs/1234567.89/results&lt;/A&gt; --get -d output_mode=csv -o test.csv&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;After this step, if the search job isn't done, then the exported csv will be empty. I've tried to use the python command .sleep(60), but it only works if I'm searching earliest=@min-1min&lt;/P&gt;</description>
      <pubDate>Fri, 18 Aug 2017 17:23:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/REST-API-to-automate-CSV-creation-export-using-Python-script/m-p/373900#M67767</guid>
      <dc:creator>jofermin</dc:creator>
      <dc:date>2017-08-18T17:23:43Z</dc:date>
    </item>
    <item>
      <title>Re: REST API to automate CSV creation/export using Python script</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/REST-API-to-automate-CSV-creation-export-using-Python-script/m-p/373901#M67768</link>
      <description>&lt;P&gt;You need to check the status of the job and when isDone = 1, then fetch the results.  You can find the status here:&lt;/P&gt;

&lt;P&gt;curl -u user:pass -k &lt;A href="https://splunk.domain.com:8089/services/search/jobs/1234567.89/"&gt;https://splunk.domain.com:8089/services/search/jobs/1234567.89/&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;So you'll need a loop in your code that checks status.&lt;/P&gt;</description>
      <pubDate>Fri, 18 Aug 2017 18:00:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/REST-API-to-automate-CSV-creation-export-using-Python-script/m-p/373901#M67768</guid>
      <dc:creator>jkat54</dc:creator>
      <dc:date>2017-08-18T18:00:39Z</dc:date>
    </item>
    <item>
      <title>Re: REST API to automate CSV creation/export using Python script</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/REST-API-to-automate-CSV-creation-export-using-Python-script/m-p/373902#M67769</link>
      <description>&lt;P&gt;Hey jkat, when I run that command, I receive an XML that has a bunch of &lt;CODE&gt;&amp;lt;s:key name=.....&amp;gt;&lt;/CODE&gt; but there is no bool called isComplete.&lt;/P&gt;</description>
      <pubDate>Fri, 18 Aug 2017 18:11:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/REST-API-to-automate-CSV-creation-export-using-Python-script/m-p/373902#M67769</guid>
      <dc:creator>jofermin</dc:creator>
      <dc:date>2017-08-18T18:11:34Z</dc:date>
    </item>
    <item>
      <title>Re: REST API to automate CSV creation/export using Python script</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/REST-API-to-automate-CSV-creation-export-using-Python-script/m-p/373903#M67770</link>
      <description>&lt;P&gt;Ah I found the bool it's &lt;CODE&gt;&amp;lt;s:key name="isDone"&amp;gt;1&amp;lt;/s:key&amp;gt;&lt;/CODE&gt;thanks&lt;/P&gt;</description>
      <pubDate>Fri, 18 Aug 2017 19:41:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/REST-API-to-automate-CSV-creation-export-using-Python-script/m-p/373903#M67770</guid>
      <dc:creator>jofermin</dc:creator>
      <dc:date>2017-08-18T19:41:33Z</dc:date>
    </item>
    <item>
      <title>Re: REST API to automate CSV creation/export using Python script</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/REST-API-to-automate-CSV-creation-export-using-Python-script/m-p/373904#M67771</link>
      <description>&lt;P&gt;Thanks I updated my answer.  &lt;/P&gt;</description>
      <pubDate>Fri, 18 Aug 2017 19:56:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/REST-API-to-automate-CSV-creation-export-using-Python-script/m-p/373904#M67771</guid>
      <dc:creator>jkat54</dc:creator>
      <dc:date>2017-08-18T19:56:19Z</dc:date>
    </item>
  </channel>
</rss>

