<?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: Import XML response via Python in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/Import-XML-response-via-Python/m-p/708062#M19581</link>
    <description>&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;HI&amp;nbsp;@Anonymous&lt;/a&gt;&amp;nbsp;,&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;According to your description, it seems more related to python script. I'd like to suggest you to post this to python script related forum to get better support.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;&lt;A href="https://www.python.org/community/forums/" target="_self"&gt;Python _ Forums&lt;/A&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;In addition, you can also take a look at following link about same requirement:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;&lt;A href="https://stackoverflow.com/questions/18308529/python-requests-package-handling-xml-response" target="_self"&gt;Python Requests package: Handling xml response&lt;/A&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Calibri; font-size: 11.0pt;"&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;&lt;EM&gt;Please understand that this link is provided with no warranties or guarantees of content changes, and confers no rights.&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;Regards,&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;Xiaoxin Sheng&lt;/FONT&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 06 Jun 2019 02:06:42 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2019-06-06T02:06:42Z</dc:date>
    <item>
      <title>Import XML response via Python</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Import-XML-response-via-Python/m-p/706645#M19576</link>
      <description>&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to import a SOAP XML response using Python onto the data model, but clearly I am missing something. When using "Get Data" and adding the Python script, it does not return any data however on the interpreter, I can see the XML. This is the Python code:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;PRE&gt;import requests
url='[REQUEST URL]'
headers = {'Content-Type': 'text/xml;charset=UTF-8', 'SOAPAction': 'uri:FlexForce/wsdlGetEmployees'}
body = """&amp;lt;soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:uri="uri:FlexForce"&amp;gt;
&amp;lt;soapenv:Header/&amp;gt;
   &amp;lt;soapenv:Body&amp;gt;
      &amp;lt;uri:wsdlGetEmployees soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"&amp;gt;
         &amp;lt;apiKey xsi:type="xsd:string"&amp;gt;xxxx-xxxx-xxxx-xxxx&amp;lt;/apiKey&amp;gt;
      &amp;lt;/uri:wsdlGetEmployees&amp;gt;
   &amp;lt;/soapenv:Body&amp;gt;
&amp;lt;/soapenv:Envelope&amp;gt;"""
response = requests.post(url,data=body,headers=headers)
print (response.content)&lt;/PRE&gt;&lt;P&gt;Can you please help?&lt;/P&gt;</description>
      <pubDate>Tue, 04 Jun 2019 13:36:44 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Import-XML-response-via-Python/m-p/706645#M19576</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-06-04T13:36:44Z</dc:date>
    </item>
    <item>
      <title>Re: Import XML response via Python</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Import-XML-response-via-Python/m-p/708062#M19581</link>
      <description>&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;HI&amp;nbsp;@Anonymous&lt;/a&gt;&amp;nbsp;,&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;According to your description, it seems more related to python script. I'd like to suggest you to post this to python script related forum to get better support.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;&lt;A href="https://www.python.org/community/forums/" target="_self"&gt;Python _ Forums&lt;/A&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;In addition, you can also take a look at following link about same requirement:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;&lt;A href="https://stackoverflow.com/questions/18308529/python-requests-package-handling-xml-response" target="_self"&gt;Python Requests package: Handling xml response&lt;/A&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Calibri; font-size: 11.0pt;"&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;&lt;EM&gt;Please understand that this link is provided with no warranties or guarantees of content changes, and confers no rights.&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;Regards,&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;Xiaoxin Sheng&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Jun 2019 02:06:42 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Import-XML-response-via-Python/m-p/708062#M19581</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-06-06T02:06:42Z</dc:date>
    </item>
    <item>
      <title>Re: Import XML response via Python</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Import-XML-response-via-Python/m-p/708333#M19584</link>
      <description>&lt;P&gt;Hi&amp;nbsp;@Anonymous&lt;/a&gt;&amp;nbsp; and thanks for replying.&lt;BR /&gt;&lt;BR /&gt;I have found a solution within my company as we have someone who knows Python in another department, and the finished code is this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;import requests
url='[REQUEST URL]'
headers = {'Content-Type': 'text/xml;charset=UTF-8', 'SOAPAction': 'uri:FlexForce/wsdlGetEmployees'}
body = """&amp;lt;soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:uri="uri:FlexForce"&amp;gt;
&amp;lt;soapenv:Header/&amp;gt;
   &amp;lt;soapenv:Body&amp;gt;
      &amp;lt;uri:wsdlGetEmployees soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"&amp;gt;
         &amp;lt;apiKey xsi:type="xsd:string"&amp;gt;xxxx-xxxx-xxxx-xxxx&amp;lt;/apiKey&amp;gt;
      &amp;lt;/uri:wsdlGetEmployees&amp;gt;
   &amp;lt;/soapenv:Body&amp;gt;
&amp;lt;/soapenv:Envelope&amp;gt;"""
response = requests.post(url,data=body,headers=headers)
content=response.content

import pandas as pd
import xml.etree.ElementTree as ET
#parses the raw response into an ElementTree object
etree = ET.fromstring(content)

def iter_employees(xml_etree):
    #this selects elements in the xml until we get to the return node
    #which contains the items, then we iterate over the items
    for each in xml_etree[0][0][0].iter('item'):
        #for each item, we add to a dictionary the tag and text as a key:value pair
        #while iterating over all tags present
        my_dict={}
        for info in list(each):
            my_dict[info.tag]=info.text
        #yielding the dictionary allows this function to provide a list of dictionaries
        yield my_dict

#we create the dataframe using the above function to pass a list of the dictionaries
#to the initialising function. The keys become the column names and the values the content
df=pd.DataFrame(list(iter_employees(etree)))&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The second part may vary according to how XML response is formatted, but I will leave this here as a reference should anyone face the same issue. Basically you need to get the response and parse it into a pandas dataframe so PBI can read it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There are a few variations to this as you can export the XML response to a file, or a parsed CSV to a CSV file and then import it to PBI but this will completely eliminate the need for ZappySys integration for SOAP XML.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Jun 2019 08:04:31 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Import-XML-response-via-Python/m-p/708333#M19584</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-06-06T08:04:31Z</dc:date>
    </item>
  </channel>
</rss>

