<?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 Python Splunk API example? in Splunk Dev</title>
    <link>https://community.splunk.com/t5/Splunk-Dev/Python-Splunk-API-example/m-p/246571#M3094</link>
    <description>&lt;P&gt;Working on using the python rest api example, I get an error on step 3&lt;/P&gt;

&lt;P&gt;myhttp.add_credentials(username, password)&lt;BR /&gt;
servicessearchstatusstr = '/services/search/jobs/%s/' % sid&lt;/P&gt;

&lt;P&gt;For this step, I have defined the password above and have used for a curl syntax and it works.&lt;BR /&gt;
But when I run the code, it will always return an Unauthorized response.&lt;/P&gt;

&lt;P&gt;I tried changing password to 'actualpass'&lt;BR /&gt;
eg. &lt;BR /&gt;
myhttp.add_credentials(username, 'actual pass')&lt;BR /&gt;
...and it runs.&lt;/P&gt;

&lt;P&gt;i also tried printing the variable password above that line and it stills shows me the correct password.&lt;BR /&gt;
I went one step further and tested with another variable above it&lt;BR /&gt;
eg.&lt;BR /&gt;
pwd = 'actual pass'&lt;BR /&gt;
myhttp.add_credentials(username, pwd)&lt;BR /&gt;
and it works.&lt;/P&gt;

&lt;P&gt;if I write &lt;BR /&gt;
eg.&lt;BR /&gt;
pwd = password&lt;BR /&gt;
myhttp.add_credentials(username, password)&lt;BR /&gt;
it does not run.&lt;/P&gt;

&lt;P&gt;I apologise if this has been covered before, but I have searched and searched but to no avail.&lt;BR /&gt;
I am just starting out but I hope to learn more.&lt;/P&gt;

&lt;P&gt;Regards,&lt;BR /&gt;
Eugene&lt;/P&gt;</description>
    <pubDate>Mon, 25 Jan 2016 12:46:38 GMT</pubDate>
    <dc:creator>obviouslygene</dc:creator>
    <dc:date>2016-01-25T12:46:38Z</dc:date>
    <item>
      <title>Python Splunk API example?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Python-Splunk-API-example/m-p/246571#M3094</link>
      <description>&lt;P&gt;Working on using the python rest api example, I get an error on step 3&lt;/P&gt;

&lt;P&gt;myhttp.add_credentials(username, password)&lt;BR /&gt;
servicessearchstatusstr = '/services/search/jobs/%s/' % sid&lt;/P&gt;

&lt;P&gt;For this step, I have defined the password above and have used for a curl syntax and it works.&lt;BR /&gt;
But when I run the code, it will always return an Unauthorized response.&lt;/P&gt;

&lt;P&gt;I tried changing password to 'actualpass'&lt;BR /&gt;
eg. &lt;BR /&gt;
myhttp.add_credentials(username, 'actual pass')&lt;BR /&gt;
...and it runs.&lt;/P&gt;

&lt;P&gt;i also tried printing the variable password above that line and it stills shows me the correct password.&lt;BR /&gt;
I went one step further and tested with another variable above it&lt;BR /&gt;
eg.&lt;BR /&gt;
pwd = 'actual pass'&lt;BR /&gt;
myhttp.add_credentials(username, pwd)&lt;BR /&gt;
and it works.&lt;/P&gt;

&lt;P&gt;if I write &lt;BR /&gt;
eg.&lt;BR /&gt;
pwd = password&lt;BR /&gt;
myhttp.add_credentials(username, password)&lt;BR /&gt;
it does not run.&lt;/P&gt;

&lt;P&gt;I apologise if this has been covered before, but I have searched and searched but to no avail.&lt;BR /&gt;
I am just starting out but I hope to learn more.&lt;/P&gt;

&lt;P&gt;Regards,&lt;BR /&gt;
Eugene&lt;/P&gt;</description>
      <pubDate>Mon, 25 Jan 2016 12:46:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Python-Splunk-API-example/m-p/246571#M3094</guid>
      <dc:creator>obviouslygene</dc:creator>
      <dc:date>2016-01-25T12:46:38Z</dc:date>
    </item>
    <item>
      <title>Re: Python Splunk API example?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Python-Splunk-API-example/m-p/246572#M3095</link>
      <description>&lt;P&gt;Can you please provide the URL for the example page you are looking at?&lt;/P&gt;</description>
      <pubDate>Mon, 25 Jan 2016 22:36:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Python-Splunk-API-example/m-p/246572#M3095</guid>
      <dc:creator>ChrisG</dc:creator>
      <dc:date>2016-01-25T22:36:29Z</dc:date>
    </item>
    <item>
      <title>Re: Python Splunk API example?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Python-Splunk-API-example/m-p/246573#M3096</link>
      <description>&lt;P&gt;Hey Chris,&lt;BR /&gt;
Thanks for the reply!&lt;BR /&gt;
The URL is &lt;A href="http://blogs.splunk.com/2011/08/02/splunk-rest-api-is-easy-to-use/"&gt;http://blogs.splunk.com/2011/08/02/splunk-rest-api-is-easy-to-use/&lt;/A&gt;&lt;BR /&gt;
But I found out one of the reasons why its not working.&lt;BR /&gt;
There was a return carriage hidden when a the login credential file was created.&lt;/P&gt;

&lt;P&gt;Sorry for the trouble, but it sure taught me a ton about checking those stuff first...&lt;/P&gt;</description>
      <pubDate>Tue, 26 Jan 2016 01:26:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Python-Splunk-API-example/m-p/246573#M3096</guid>
      <dc:creator>obviouslygene</dc:creator>
      <dc:date>2016-01-26T01:26:24Z</dc:date>
    </item>
    <item>
      <title>Re: Python Splunk API example?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Python-Splunk-API-example/m-p/246574#M3097</link>
      <description>&lt;P&gt;@obviouslygene, glad you figured it out! Would you mind putting that down as an answer below and accepting it? If someone in the future has the same problem it will really help them out!&lt;/P&gt;</description>
      <pubDate>Tue, 26 Jan 2016 12:25:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Python-Splunk-API-example/m-p/246574#M3097</guid>
      <dc:creator>jplumsdaine22</dc:creator>
      <dc:date>2016-01-26T12:25:08Z</dc:date>
    </item>
    <item>
      <title>Re: Python Splunk API example?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Python-Splunk-API-example/m-p/246575#M3098</link>
      <description>&lt;P&gt;ok will post down below.&lt;/P&gt;</description>
      <pubDate>Fri, 29 Jan 2016 01:11:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Python-Splunk-API-example/m-p/246575#M3098</guid>
      <dc:creator>obviouslygene</dc:creator>
      <dc:date>2016-01-29T01:11:59Z</dc:date>
    </item>
    <item>
      <title>Re: Python Splunk API example?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Python-Splunk-API-example/m-p/246576#M3099</link>
      <description>&lt;P&gt;I was pulling the password from a credentials.csv and I realized that even nothing worked, It kept telling me that I was unauthorized.&lt;BR /&gt;
I switched the first part of the example to run by curl and it passed the password variable through fine.&lt;BR /&gt;
Step 2 worked as well, but Step 3 I couldn't get it to work.&lt;BR /&gt;
I then found out why, there was a return carriage in the .csv file some how, even though it didnt look like it.&lt;/P&gt;

&lt;P&gt;So this was what I did to solve it. The code looked something like this (bear with me I'm pretty new to coding.)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;f = open('login.csv', 'rb')
for field in f.readlines():
    fsc = field.rstrip()
    password = fsc.split(',')[1]
f.close()
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;That solved the issue.&lt;/P&gt;</description>
      <pubDate>Fri, 29 Jan 2016 01:16:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Python-Splunk-API-example/m-p/246576#M3099</guid>
      <dc:creator>obviouslygene</dc:creator>
      <dc:date>2016-01-29T01:16:38Z</dc:date>
    </item>
  </channel>
</rss>

