<?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: POST request with Power Query fails auth but needs to be Anonymous in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/POST-request-with-Power-Query-fails-auth-but-needs-to-be/m-p/3978332#M154253</link>
    <description>&lt;P&gt;&lt;FONT&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="673722" data-lia-user-login="JangoChained" class="lia-mention lia-mention-user"&gt;JangoChained&lt;/a&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT&gt;In Power BI, when issuing a POST request using this function, you need to ensure that the API key is properly included in the header.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT&gt;If you are using the API key for authentication, you typically need to include it in the request's header.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT&gt;Here is an example of how to use the header constructor:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;let
    url = "Your_API_Endpoint",
    body = "Your_Body_Content",
    apikey = "Your_API_Key",
    headers = [#"Content-Type"="application/json", #"Authorization"= "Bearer " &amp;amp; apikey],
    Source = Json.Document(Web.Contents(url, [Headers=headers, Content=Text.ToBinary(body)]))
in
    Source&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT&gt;The HTTP request is made as either a GET (when no Content is specified) or a POST (when there is Content). POST requests may only be made anonymously.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT&gt;Web.Contents&amp;nbsp;is used for retrieving web content that doesn't need to be accessed through a browser, such as CSV files, JSON API results, and so on.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class="" style="background: white;"&gt;&lt;FONT&gt;&lt;SPAN&gt;You can view the link below for more details:&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT&gt;&lt;A href="https://learn.microsoft.com/en-us/powerquery-m/web-contents" target="_blank" rel="noopener"&gt;Web.Contents - PowerQuery M | Microsoft Learn&amp;nbsp;&lt;/A&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT&gt;&lt;A href="https://learn.microsoft.com/en-us/power-query/connectors/web/web-troubleshoot" target="_blank" rel="noopener"&gt;Troubleshooting the Power Query Web connector - Power Query | Microsoft Learn&lt;/A&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P data-unlink="true"&gt;&lt;FONT&gt;You can post in the Power Query forum so you can get more professional help.&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P data-unlink="true"&gt;&lt;FONT&gt;Regards,&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;P data-unlink="true"&gt;&lt;FONT&gt;Nono Chen&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;P data-unlink="true"&gt;&lt;FONT&gt;If this &lt;STRONG&gt;&lt;EM&gt;post&amp;nbsp;&lt;/EM&gt;&lt;/STRONG&gt;helps, then please consider&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;&lt;STRONG&gt;&lt;EM&gt;Accept it as the solution&lt;/EM&gt;&lt;/STRONG&gt;&lt;/EM&gt;&lt;/STRONG&gt;&amp;nbsp;to help the other members find it more quickly.&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 07 Jun 2024 02:01:10 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2024-06-07T02:01:10Z</dc:date>
    <item>
      <title>POST request with Power Query fails auth but needs to be Anonymous</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/POST-request-with-Power-Query-fails-auth-but-needs-to-be/m-p/3976372#M154176</link>
      <description>&lt;P&gt;The Web.Contents function needs to specify content for making a POST request, but can`t get auth right. I pass the credentials (APIKey) and it works on Postman, but if I do it anonymous in PB it fails saying that can`t verify the credentials, but if I change it to basic auth PB tells me that the query needs to be from anonymous source. The code looks like this, the main part ends at JsonResponse, I don't think that the transformation of data matters for this problem.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;</description>
      <pubDate>Thu, 06 Jun 2024 07:38:31 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/POST-request-with-Power-Query-fails-auth-but-needs-to-be/m-p/3976372#M154176</guid>
      <dc:creator>JangoChained</dc:creator>
      <dc:date>2024-06-06T07:38:31Z</dc:date>
    </item>
    <item>
      <title>Re: POST request with Power Query fails auth but needs to be Anonymous</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/POST-request-with-Power-Query-fails-auth-but-needs-to-be/m-p/3978332#M154253</link>
      <description>&lt;P&gt;&lt;FONT&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="673722" data-lia-user-login="JangoChained" class="lia-mention lia-mention-user"&gt;JangoChained&lt;/a&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT&gt;In Power BI, when issuing a POST request using this function, you need to ensure that the API key is properly included in the header.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT&gt;If you are using the API key for authentication, you typically need to include it in the request's header.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT&gt;Here is an example of how to use the header constructor:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;let
    url = "Your_API_Endpoint",
    body = "Your_Body_Content",
    apikey = "Your_API_Key",
    headers = [#"Content-Type"="application/json", #"Authorization"= "Bearer " &amp;amp; apikey],
    Source = Json.Document(Web.Contents(url, [Headers=headers, Content=Text.ToBinary(body)]))
in
    Source&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT&gt;The HTTP request is made as either a GET (when no Content is specified) or a POST (when there is Content). POST requests may only be made anonymously.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT&gt;Web.Contents&amp;nbsp;is used for retrieving web content that doesn't need to be accessed through a browser, such as CSV files, JSON API results, and so on.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class="" style="background: white;"&gt;&lt;FONT&gt;&lt;SPAN&gt;You can view the link below for more details:&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT&gt;&lt;A href="https://learn.microsoft.com/en-us/powerquery-m/web-contents" target="_blank" rel="noopener"&gt;Web.Contents - PowerQuery M | Microsoft Learn&amp;nbsp;&lt;/A&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT&gt;&lt;A href="https://learn.microsoft.com/en-us/power-query/connectors/web/web-troubleshoot" target="_blank" rel="noopener"&gt;Troubleshooting the Power Query Web connector - Power Query | Microsoft Learn&lt;/A&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P data-unlink="true"&gt;&lt;FONT&gt;You can post in the Power Query forum so you can get more professional help.&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P data-unlink="true"&gt;&lt;FONT&gt;Regards,&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;P data-unlink="true"&gt;&lt;FONT&gt;Nono Chen&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;P data-unlink="true"&gt;&lt;FONT&gt;If this &lt;STRONG&gt;&lt;EM&gt;post&amp;nbsp;&lt;/EM&gt;&lt;/STRONG&gt;helps, then please consider&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;&lt;STRONG&gt;&lt;EM&gt;Accept it as the solution&lt;/EM&gt;&lt;/STRONG&gt;&lt;/EM&gt;&lt;/STRONG&gt;&amp;nbsp;to help the other members find it more quickly.&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Jun 2024 02:01:10 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/POST-request-with-Power-Query-fails-auth-but-needs-to-be/m-p/3978332#M154253</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-06-07T02:01:10Z</dc:date>
    </item>
    <item>
      <title>Re: POST request with Power Query fails auth but needs to be Anonymous</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/POST-request-with-Power-Query-fails-auth-but-needs-to-be/m-p/3978875#M154275</link>
      <description>&lt;P&gt;Hi Nono, thx for the help. I was close enough, i just needed to ajust my query. This is the solution I got, the apiKey is in the body because I did it with x-www-form-urlencoded, from my testing in Postman (because this is a call to a custom function in an API).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;</description>
      <pubDate>Fri, 07 Jun 2024 07:05:20 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/POST-request-with-Power-Query-fails-auth-but-needs-to-be/m-p/3978875#M154275</guid>
      <dc:creator>JangoChained</dc:creator>
      <dc:date>2024-06-07T07:05:20Z</dc:date>
    </item>
  </channel>
</rss>

