Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
yanika_a
New Member

Power Query - API

Hi all, 

 

I am using a Power Query to query an API (Xero API) but I am struggling with the transformation of data resulting from the API GET request to a table format. Details below; 

 

This is my Query; 

 

let
AccessToken = "Bearer xxxxxxxxxxxxxxxxxxxxxxxxxxxx",
 Source = Table.FromColumns({Lines.FromBinary(Web.Contents("https://api.xero.com/api.xro/2.0/Contacts", [Headers=[#"Content-Type"="application/json", #"xero-tenant-id"="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", #"Accept"= "application/json", Authorization=AccessToken]]), null, null, 65001)}),
#"Parsed XML" = Table.TransformColumns(Source,{},Xml.Tables)
in
#"Parsed XML""

 

Source returns the following result, all in 1 Column ; 

 

yanika_a_1-1637226420956.png

 

Full xml;

 

 

"<Response xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"">"
  <Id>78e84298-d216-4e81-bd85-a86dfacdea98</Id>
  <Status>OK</Status>
  <ProviderName>PurchInvAutomation</ProviderName>
  <DateTimeUTC>2021-11-18T08:38:07.466739Z</DateTimeUTC>
  <Contacts>
	<Contact>
      <ContactID>8a777d01-8bfb-4623-807d-189d3f077e81</ContactID>
      <ContactStatus>ACTIVE</ContactStatus>
      <Name>John Doe</Name>
      <Addresses>
        <Address>
          <AddressType>POBOX</AddressType>
        </Address>
        <Address>
          <AddressType>STREET</AddressType>
        </Address>
      </Addresses>
      <Phones>
        <Phone>
          <PhoneType>DDI</PhoneType>
        </Phone>
        <Phone>
          <PhoneType>DEFAULT</PhoneType>
        </Phone>
        <Phone>
          <PhoneType>FAX</PhoneType>
        </Phone>
        <Phone>
          <PhoneType>MOBILE</PhoneType>
        </Phone>
      </Phones>
      <UpdatedDateUTC>2021-11-17T18:03:41.873</UpdatedDateUTC>
      <IsSupplier>false</IsSupplier>
      <IsCustomer>false</IsCustomer>
      <HasAttachments>false</HasAttachments>
    </Contact>
</Contacts>
</Response>

 

 

This is just one record - the response contains more than one. 

 

I tried to use Table.Transform columns in #"Parsed XML" and it returns the below; 

 

yanika_a_0-1637226313489.png

 

 

Would anyone know how can I transform the above XML to table format - example; 

 

ContactIDContactNumberContactstatusNameFirstNameLastName
8a777d01-8bfb-4623-807d-189d3f077e8199d248f11c2540af002806840bf3be3bfa95dd7f7afac17d3cACTIVEJohn DoeJohnDoe
9b777d01-8bfb-4623-807d-189d3f077e8110d248f11c2540af002806840bf3be3bfa95dd7f7afac17d3cACTIVEJane DoeJaneDoe

 

Thanks in advance! 

2 REPLIES 2
v-jingzhang
Community Support
Community Support

Hi @yanika_a 

 

Can you first try below query and let me know what result does this Source step return?

 

let
AccessToken = "Bearer xxxxxxxxxxxxxxxxxxxxxxxxxxxx",
Source = Web.Contents("https://api.xero.com/api.xro/2.0/Contacts", [Headers=[#"Content-Type"="application/json", #"xero-tenant-id"="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", #"Accept"= "application/json", Authorization=AccessToken]])
in
Source

 

 

If it's possible to transform the response data into a table that each row has an XML record, then things will get easy. 

 

Use Xml.Tables to wrap the XML content. Then expand Contacts column. Detailed information in Contacts will be expanded to the same row. To get FirstName and LastName column, you can duplicate Name column first, then split the Name-Copy column by delimiter. 

21112402.jpg

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

Gabriel_Walkman
Continued Contributor
Continued Contributor

I'm not familiar with xml's, but what does that button in the top right corner of your last image do?

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.