<?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: Empty response in Python SDK example a.py ? in Splunk Dev</title>
    <link>https://community.splunk.com/t5/Splunk-Dev/Empty-response-in-Python-SDK-example-a-py/m-p/233925#M2979</link>
    <description>&lt;P&gt;It looks like the connection was being closed before the response was being read.. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;        try:
            connection.request("POST", "/services/auth/login", body, headers)
            response = connection.getresponse()
        finally:
            **connection.close()**
        if response.status != 200:
            raise Exception, "%d (%s)" % (response.status, response.reason)
        **body = response.read()**
        sessionKey = ElementTree.XML(body).findtext("./sessionKey")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If you fix it up a little, it will work..&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;        try:
            connection.request("POST", "/services/auth/login", body, headers)
            response = connection.getresponse()
        finally:
            **#connection.close()**
            print ''
        if response.status != 200:
            raise Exception, "%d (%s)" % (response.status, response.reason)
        **body = response.read()**
        **connection.close()**
        sessionKey = ElementTree.XML(body).findtext("./sessionKey")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I'm wondering if anyone else has ever used this example &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 05 Oct 2016 18:53:47 GMT</pubDate>
    <dc:creator>smeier</dc:creator>
    <dc:date>2016-10-05T18:53:47Z</dc:date>
    <item>
      <title>Empty response in Python SDK example a.py ?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Empty-response-in-Python-SDK-example-a-py/m-p/233924#M2978</link>
      <description>&lt;P&gt;I am working through the Python SDK and getting this error on the first script.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Traceback (most recent call last):
  File "C:\Users\.\Downloads\splunk-sdk-python-1.6.0\examples\abc\a.py", line 49, in &amp;lt;module&amp;gt;
    sessionKey = ElementTree.XML(body).findtext("./sessionKey")
  File "C:\Python27\lib\xml\etree\ElementTree.py", line 1312, in XML
    return parser.close()
  File "C:\Python27\lib\xml\etree\ElementTree.py", line 1665, in close
    self._raiseerror(v)
  File "C:\Python27\lib\xml\etree\ElementTree.py", line 1517, in _raiseerror
    raise err
ParseError: no element found: line 1, column 0
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I tried printing the contents of 'body' and it is empty.&lt;/P&gt;</description>
      <pubDate>Wed, 05 Oct 2016 17:58:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Empty-response-in-Python-SDK-example-a-py/m-p/233924#M2978</guid>
      <dc:creator>smeier</dc:creator>
      <dc:date>2016-10-05T17:58:50Z</dc:date>
    </item>
    <item>
      <title>Re: Empty response in Python SDK example a.py ?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Empty-response-in-Python-SDK-example-a-py/m-p/233925#M2979</link>
      <description>&lt;P&gt;It looks like the connection was being closed before the response was being read.. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;        try:
            connection.request("POST", "/services/auth/login", body, headers)
            response = connection.getresponse()
        finally:
            **connection.close()**
        if response.status != 200:
            raise Exception, "%d (%s)" % (response.status, response.reason)
        **body = response.read()**
        sessionKey = ElementTree.XML(body).findtext("./sessionKey")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If you fix it up a little, it will work..&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;        try:
            connection.request("POST", "/services/auth/login", body, headers)
            response = connection.getresponse()
        finally:
            **#connection.close()**
            print ''
        if response.status != 200:
            raise Exception, "%d (%s)" % (response.status, response.reason)
        **body = response.read()**
        **connection.close()**
        sessionKey = ElementTree.XML(body).findtext("./sessionKey")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I'm wondering if anyone else has ever used this example &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Oct 2016 18:53:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Empty-response-in-Python-SDK-example-a-py/m-p/233925#M2979</guid>
      <dc:creator>smeier</dc:creator>
      <dc:date>2016-10-05T18:53:47Z</dc:date>
    </item>
  </channel>
</rss>

