<?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 2 arguments were passed to a function which expects 1 in Custom Visuals Development Discussion</title>
    <link>https://community.fabric.microsoft.com/t5/Custom-Visuals-Development/2-arguments-were-passed-to-a-function-which-expects-1/m-p/851557#M2761</link>
    <description>&lt;P&gt;Hi there fellow users of Power Bi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to obtain some data using an API.&lt;/P&gt;&lt;P&gt;I have managed to get the authentication token and managed to obtain some data, but only the first 100 items.&lt;/P&gt;&lt;P&gt;So now I am trying to loop through all the "pages" using count and an offset.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;However I get the following error:&lt;BR /&gt;2 arguments were passed to a function which expects 1.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The below is my code, hopefully you can help me out&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;let
// Get authorization token
Kilde = Web.Contents("https://api.XXXXXXXXX.dk/oauth2/token",
[Headers=[#"Content-Type"="application/x-www-form-urlencoded"],
Content=Text.ToBinary(Uri.BuildQueryString([grant_type="password", client_id="XXXXXXXXXXXXXXXXX", client_secret="XXXXXXXXXXXXXX", email="xxxxxxx@yyyyyyyyy.com", password="XXXXXXXXXXXXX"]))]),
KildeTekst = Text.FromBinary(Kilde),
KildeSegmenter = Splitter.SplitTextByDelimiter("&amp;amp;")(KildeTekst),
KildeKvps = List.Transform( KildeSegmenter,
(value) =&amp;gt; {
List.First((Splitter.SplitTextByDelimiter("=")(value))),
List.Last((Splitter.SplitTextByDelimiter("=")(value)))
}
),
KildeKvpTabel = Table.FromList(KildeSegmenter, Splitter.SplitTextByDelimiter("=")),
#"Filtrerede rækker" = Table.SelectColumns(Table.SelectRows(KildeKvpTabel, each [Column1] = "access_token"), {"Column2"}),
Token = Text.From(List.First(Table.SelectColumns(Table.SelectRows(KildeKvpTabel, each [Column1] = "access_token"), {"Column2"})[Column2])),


EntitiesPerPage = 100,
BaseUrl = "https://api.xxxxxxxxxxx.dk/v1/organizations/XXXX/vouchers",


GetJson = (Url) =&amp;gt;
let Options = [Headers =[#"Authorization"="Bearer " &amp;amp; Token]],
RawData = Web.Contents(Url, Options),
Json = Json.Document(RawData,1252)
in Json,


GetEntityCount = () =&amp;gt;
let Url = BaseUrl &amp;amp; "?count=10",
Options = [Headers =[#"Authorization"="Bearer " &amp;amp; Token]],
Json = Web.Contents(Url, Options),
#"Derp" = Json.Document(Json,1252),
Count = Record.Field(#"Derp"[meta],"count")
in Count,


GetPage = (Index) =&amp;gt;
let
Options = [Headers =[#"Authorization"="Bearer " &amp;amp; Token]],
Skip = "&amp;amp;offset=" &amp;amp; Text.From(Index * EntitiesPerPage),
Top = "?count=" &amp;amp; Text.From(EntitiesPerPage),
Url = BaseUrl &amp;amp; Top &amp;amp; Skip,
Json = GetJson(Url, Options),
Value = Json[#"value"]
in Value,


EntityCount = List.Max({ EntitiesPerPage, GetEntityCount() }),
PageCount = Number.RoundUp(EntityCount / EntitiesPerPage),
PageIndices = { 0 .. PageCount - 1 },
Pages = List.Transform(PageIndices, each GetPage(_)),
Entities = List.Union(Pages),
Table = Table.FromList(Entities, Splitter.SplitByNothing(), null, null, ExtraValues.Error)

in
Table&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am pretty sure it's:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Pages = List.Transform(PageIndices, each GetPage(_)),&lt;/LI-CODE&gt;&lt;P&gt;Which is causing the issue.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I take a look at GetPage = (Index) =&amp;gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I noticed in Postman it's returning me a data and meta tag:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Value = Json[#"value"]&lt;/LI-CODE&gt;&lt;P&gt;with&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Value = Json[data][#"value"]&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;But sadly without luck.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I really hope someone can help me, since I am pulling my hair out over this issue :S&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Feel free to add me on skype: Futurelinkhev or hev@futurelink.dk if needed be &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Best regards&lt;/P&gt;</description>
    <pubDate>Wed, 20 Nov 2019 10:00:42 GMT</pubDate>
    <dc:creator>Shamatix</dc:creator>
    <dc:date>2019-11-20T10:00:42Z</dc:date>
    <item>
      <title>2 arguments were passed to a function which expects 1</title>
      <link>https://community.fabric.microsoft.com/t5/Custom-Visuals-Development/2-arguments-were-passed-to-a-function-which-expects-1/m-p/851557#M2761</link>
      <description>&lt;P&gt;Hi there fellow users of Power Bi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to obtain some data using an API.&lt;/P&gt;&lt;P&gt;I have managed to get the authentication token and managed to obtain some data, but only the first 100 items.&lt;/P&gt;&lt;P&gt;So now I am trying to loop through all the "pages" using count and an offset.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;However I get the following error:&lt;BR /&gt;2 arguments were passed to a function which expects 1.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The below is my code, hopefully you can help me out&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;let
// Get authorization token
Kilde = Web.Contents("https://api.XXXXXXXXX.dk/oauth2/token",
[Headers=[#"Content-Type"="application/x-www-form-urlencoded"],
Content=Text.ToBinary(Uri.BuildQueryString([grant_type="password", client_id="XXXXXXXXXXXXXXXXX", client_secret="XXXXXXXXXXXXXX", email="xxxxxxx@yyyyyyyyy.com", password="XXXXXXXXXXXXX"]))]),
KildeTekst = Text.FromBinary(Kilde),
KildeSegmenter = Splitter.SplitTextByDelimiter("&amp;amp;")(KildeTekst),
KildeKvps = List.Transform( KildeSegmenter,
(value) =&amp;gt; {
List.First((Splitter.SplitTextByDelimiter("=")(value))),
List.Last((Splitter.SplitTextByDelimiter("=")(value)))
}
),
KildeKvpTabel = Table.FromList(KildeSegmenter, Splitter.SplitTextByDelimiter("=")),
#"Filtrerede rækker" = Table.SelectColumns(Table.SelectRows(KildeKvpTabel, each [Column1] = "access_token"), {"Column2"}),
Token = Text.From(List.First(Table.SelectColumns(Table.SelectRows(KildeKvpTabel, each [Column1] = "access_token"), {"Column2"})[Column2])),


EntitiesPerPage = 100,
BaseUrl = "https://api.xxxxxxxxxxx.dk/v1/organizations/XXXX/vouchers",


GetJson = (Url) =&amp;gt;
let Options = [Headers =[#"Authorization"="Bearer " &amp;amp; Token]],
RawData = Web.Contents(Url, Options),
Json = Json.Document(RawData,1252)
in Json,


GetEntityCount = () =&amp;gt;
let Url = BaseUrl &amp;amp; "?count=10",
Options = [Headers =[#"Authorization"="Bearer " &amp;amp; Token]],
Json = Web.Contents(Url, Options),
#"Derp" = Json.Document(Json,1252),
Count = Record.Field(#"Derp"[meta],"count")
in Count,


GetPage = (Index) =&amp;gt;
let
Options = [Headers =[#"Authorization"="Bearer " &amp;amp; Token]],
Skip = "&amp;amp;offset=" &amp;amp; Text.From(Index * EntitiesPerPage),
Top = "?count=" &amp;amp; Text.From(EntitiesPerPage),
Url = BaseUrl &amp;amp; Top &amp;amp; Skip,
Json = GetJson(Url, Options),
Value = Json[#"value"]
in Value,


EntityCount = List.Max({ EntitiesPerPage, GetEntityCount() }),
PageCount = Number.RoundUp(EntityCount / EntitiesPerPage),
PageIndices = { 0 .. PageCount - 1 },
Pages = List.Transform(PageIndices, each GetPage(_)),
Entities = List.Union(Pages),
Table = Table.FromList(Entities, Splitter.SplitByNothing(), null, null, ExtraValues.Error)

in
Table&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am pretty sure it's:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Pages = List.Transform(PageIndices, each GetPage(_)),&lt;/LI-CODE&gt;&lt;P&gt;Which is causing the issue.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I take a look at GetPage = (Index) =&amp;gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I noticed in Postman it's returning me a data and meta tag:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Value = Json[#"value"]&lt;/LI-CODE&gt;&lt;P&gt;with&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Value = Json[data][#"value"]&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;But sadly without luck.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I really hope someone can help me, since I am pulling my hair out over this issue :S&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Feel free to add me on skype: Futurelinkhev or hev@futurelink.dk if needed be &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Best regards&lt;/P&gt;</description>
      <pubDate>Wed, 20 Nov 2019 10:00:42 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Custom-Visuals-Development/2-arguments-were-passed-to-a-function-which-expects-1/m-p/851557#M2761</guid>
      <dc:creator>Shamatix</dc:creator>
      <dc:date>2019-11-20T10:00:42Z</dc:date>
    </item>
    <item>
      <title>Re: 2 arguments were passed to a function which expects 1</title>
      <link>https://community.fabric.microsoft.com/t5/Custom-Visuals-Development/2-arguments-were-passed-to-a-function-which-expects-1/m-p/857441#M2776</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Unfortunately, Power BI API is out of my expertise so, it's better to ask the question in more relevant thread as &lt;A href="https://community.powerbi.com/t5/Developer/bd-p/Developer" target="_self"&gt;this one&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kind Regards,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Evgenii Elkin,&lt;BR /&gt;Software Engineer&lt;BR /&gt;Microsoft Power BI Custom Visuals&lt;BR /&gt;pbicvsupport@microsoft.com&lt;/P&gt;</description>
      <pubDate>Tue, 26 Nov 2019 15:59:15 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Custom-Visuals-Development/2-arguments-were-passed-to-a-function-which-expects-1/m-p/857441#M2776</guid>
      <dc:creator>v-evelk</dc:creator>
      <dc:date>2019-11-26T15:59:15Z</dc:date>
    </item>
  </channel>
</rss>

