<?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 Get data from API with token in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/Get-data-from-API-with-token/m-p/836463#M21277</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I have a problem to connect a web source :&lt;/P&gt;&lt;P&gt;I have an URL with a token authentification that is refresh every days.&lt;/P&gt;&lt;P&gt;I'm able to recover datas if i put directly the token in my url , but i have some difficulties to connect with a dynamic parameter :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;let
   url = "https://URL/token",
   body = "{""username"":""XXXX"",""password"":""XXXX""}",
   token = Json.Document(Web.Contents(url, [Headers=[#"Content-Type"="application/json"], Content=Text.ToBinary(body)])),
   TokenBin = Json.FromValue(token),
   TokenText = Binary.ToText(TokenBin),
   AccessTokenHeader = "bearer " &amp;amp; TokenText,
   localbusiness = Web.Contents("https://URL/localbusiness", [Headers=[Authorization=AccessTokenHeader]])
in
localbusiness&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I notice that on the step where I try to convert the binary value to text, the text string change and make my token invalid.&lt;/P&gt;&lt;P&gt;How can I recover this token in dynamic ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thx&lt;/P&gt;&lt;P&gt;---------&lt;/P&gt;&lt;P&gt;Edit :&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I found a solution , it works for me :&lt;/P&gt;&lt;P&gt;Instead of using the header authorisation, I put directly the token in the url by using the Uri.BuildQuerryString function :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;let
   url = "https://URL/token",
   body = "{""username"":""XXXX"",""password"":""XXXX""}",
   token = Json.Document(Web.Contents(url, [Headers=[#"Content-Type"="application/json"],Content=Text.ToBinary(body)])),
   TokenBin = Json.Document(token),
   tokentext = Uri.BuildQueryString(tokenBin),
   source = Web.Contents("https://URL/localbusiness?"&amp;amp;tokentext),
   localbusiness= Json.Document(source),
   in
localbusiness&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hopes it will help another.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 07 Nov 2019 16:39:01 GMT</pubDate>
    <dc:creator>Pla31000</dc:creator>
    <dc:date>2019-11-07T16:39:01Z</dc:date>
    <item>
      <title>Get data from API with token</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Get-data-from-API-with-token/m-p/836463#M21277</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I have a problem to connect a web source :&lt;/P&gt;&lt;P&gt;I have an URL with a token authentification that is refresh every days.&lt;/P&gt;&lt;P&gt;I'm able to recover datas if i put directly the token in my url , but i have some difficulties to connect with a dynamic parameter :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;let
   url = "https://URL/token",
   body = "{""username"":""XXXX"",""password"":""XXXX""}",
   token = Json.Document(Web.Contents(url, [Headers=[#"Content-Type"="application/json"], Content=Text.ToBinary(body)])),
   TokenBin = Json.FromValue(token),
   TokenText = Binary.ToText(TokenBin),
   AccessTokenHeader = "bearer " &amp;amp; TokenText,
   localbusiness = Web.Contents("https://URL/localbusiness", [Headers=[Authorization=AccessTokenHeader]])
in
localbusiness&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I notice that on the step where I try to convert the binary value to text, the text string change and make my token invalid.&lt;/P&gt;&lt;P&gt;How can I recover this token in dynamic ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thx&lt;/P&gt;&lt;P&gt;---------&lt;/P&gt;&lt;P&gt;Edit :&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I found a solution , it works for me :&lt;/P&gt;&lt;P&gt;Instead of using the header authorisation, I put directly the token in the url by using the Uri.BuildQuerryString function :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;let
   url = "https://URL/token",
   body = "{""username"":""XXXX"",""password"":""XXXX""}",
   token = Json.Document(Web.Contents(url, [Headers=[#"Content-Type"="application/json"],Content=Text.ToBinary(body)])),
   TokenBin = Json.Document(token),
   tokentext = Uri.BuildQueryString(tokenBin),
   source = Web.Contents("https://URL/localbusiness?"&amp;amp;tokentext),
   localbusiness= Json.Document(source),
   in
localbusiness&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hopes it will help another.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Nov 2019 16:39:01 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Get-data-from-API-with-token/m-p/836463#M21277</guid>
      <dc:creator>Pla31000</dc:creator>
      <dc:date>2019-11-07T16:39:01Z</dc:date>
    </item>
  </channel>
</rss>

