<?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 Passing Variables into API URL - without preventing PBI Server dataset refresh in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/Passing-Variables-into-API-URL-without-preventing-PBI-Server/m-p/3931206#M52662</link>
    <description>&lt;P&gt;Hi,&lt;BR /&gt;Needed to add a dynamic varaible to my API call used a function to pass the ID number and then pull the relevant field per ID - was very happy when it all seemed to work ok in desktop.&lt;BR /&gt;Published to the PowerBI server and got a "&lt;SPAN&gt;This dataset includes a dynamic data source. Since dynamic data sources aren't refreshed in the Power BI service,"&lt;BR /&gt;&lt;/SPAN&gt;I had done some research and it seems I need to trick the PowerBI server into not treating this like a dynamic data source, possibly by moving the variable down to Web.contents - but cant get it to work.&lt;BR /&gt;&lt;BR /&gt;Current code is....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(projectIDVariabl) =&amp;gt;&lt;/P&gt;&lt;P&gt;let&lt;BR /&gt;url = "&lt;A href="https://api.workguru.io/api/ClientTokenAuth/Authenticate/api/client/v1/tokenauth" target="_blank" rel="noopener"&gt;https://api.workguru.io/api/ClientTokenAuth/Authenticate/api/client/v1/tokenauth&lt;/A&gt;",&lt;/P&gt;&lt;P&gt;body = "{ ""ApiKey"": ""XXX"", ""Secret"": ""XXX"" }",&lt;BR /&gt;tokenResponse = Json.Document(Web.Contents(url,[Headers = [#"Content-Type"="application/json"], Content = Text.ToBinary(body) ] )),&lt;BR /&gt;AccessToken = tokenResponse[accessToken],&lt;BR /&gt;AccessTokenHeader = "Bearer " &amp;amp; AccessToken,&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;data_url = "&lt;A href="https://api.workguru.io/api/services/app/Project/GetProjectById?id=" target="_blank" rel="noopener"&gt;https://api.workguru.io/api/services/app/Project/GetProjectById?id=&lt;/A&gt;&lt;FONT color="#FF0000"&gt;"&amp;amp; Number.ToText(projectIDVariabl)&amp;amp;"&lt;/FONT&gt;&amp;amp;includeProductImages=false&amp;amp;includeLineItemCustomFields=true",&lt;BR /&gt;data_body = "{&lt;BR /&gt;""authorization"": """&amp;amp; AccessTokenHeader &amp;amp; """,&lt;BR /&gt;""content-type"": ""application/json""&lt;BR /&gt;}",&lt;/P&gt;&lt;P&gt;GetGroups = Json.Document(&lt;BR /&gt;Web.Contents(&lt;BR /&gt;data_url,&lt;BR /&gt;[&lt;BR /&gt;Headers = Json.Document(data_body)&lt;BR /&gt;]&lt;BR /&gt;)&lt;BR /&gt;),&lt;BR /&gt;#"Converted to Table" = Record.ToTable(GetGroups),&lt;BR /&gt;Value1 = #"Converted to Table"{0}[Value],&lt;BR /&gt;#"Converted to Table1" = Record.ToTable(Value1),&lt;BR /&gt;#"Transposed Table" = Table.Transpose(#"Converted to Table1"),&lt;BR /&gt;#"Promoted Headers" = Table.PromoteHeaders(#"Transposed Table", [PromoteAllScalars=true]),&lt;BR /&gt;#"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"tenantId", Int64.Type}, {"projectNo", type text}, {"projectName", type text}, {"description", type text}, {"startDate", type datetime}, {"dueDate", type datetime}, {"clientId", Int64.Type}, {"billingClientId", Int64.Type}, {"projectGroupId", type any}, {"clientPurchaseOrder", type any}, {"status", type text}, {"warehouse", type any}, {"warehouseId", type any}, {"contactId", Int64.Type}, {"contact", type any}, {"billingClient", type any}, {"client", type any}, {"recurringProjectId", type any}, {"recurringProject", type any}, {"customFieldValues", type any}, {"invoices", type any}, {"timeSheets", type any}, {"notes", type any}, {"files", type any}, {"taskLineItems", type any}, {"productLineItems", type any}, {"milestones", type any}, {"stockUsage", type any}, {"clientCreditNotes", type any}, {"completedDate", type any}, {"asset", type any}, {"assetId", type any}, {"purchaseOrders", type any}, {"quoteId", type any}, {"quote", type any}, {"reportingCategoryOption1Id", Int64.Type}, {"reportingCategoryOption2Id", type any}, {"reportingCategoryOption1", type any}, {"reportingCategoryOption2", type any}, {"currency", type text}, {"exchangeRate", Int64.Type}, {"projectGroup", type any}, {"projectManagerId", Int64.Type}, {"projectManager", type any}, {"forecastTime", Int64.Type}, {"totalTime", Int64.Type}, {"total", Int64.Type}, {"baseCurrencyTotal", Int64.Type}, {"documentStorageId", type any}, {"externalSystemId", type any}, {"externalSystemWebhookKey", type any}, {"supplierCreditNotes", type any}, {"useStaffRates", type logical}, {"totalInvoiced", Int64.Type}, {"totalTax", Int64.Type}, {"cost", Int64.Type}, {"forecastCost", Int64.Type}, {"profit", Int64.Type}, {"profitPercentage", Int64.Type}, {"isProductionJob", type logical}, {"phases", type any}, {"customFieldGroupId", type any}, {"customFieldGroup", type any}, {"isDeleted", type logical}, {"deleterUserId", type any}, {"deletionTime", type any}, {"lastModificationTime", type any}, {"lastModifierUserId", type any}, {"creationTime", type datetime}, {"creatorUserId", Int64.Type}, {"id", Int64.Type}}),&lt;BR /&gt;#"Expanded customFieldValues" = Table.ExpandListColumn(#"Changed Type", "customFieldValues"),&lt;BR /&gt;#"Expanded customFieldValues1" = Table.ExpandRecordColumn(#"Expanded customFieldValues", "customFieldValues", {"customFieldId", "value"}, {"customFieldValues.customFieldId", "customFieldValues.value"}),&lt;BR /&gt;#"Filtered Rows" = Table.SelectRows(#"Expanded customFieldValues1", each ([customFieldValues.customFieldId] = 2199))&lt;BR /&gt;in&lt;BR /&gt;#"Filtered Rows"&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 20 May 2024 05:02:27 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2024-05-20T05:02:27Z</dc:date>
    <item>
      <title>Passing Variables into API URL - without preventing PBI Server dataset refresh</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Passing-Variables-into-API-URL-without-preventing-PBI-Server/m-p/3931206#M52662</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;Needed to add a dynamic varaible to my API call used a function to pass the ID number and then pull the relevant field per ID - was very happy when it all seemed to work ok in desktop.&lt;BR /&gt;Published to the PowerBI server and got a "&lt;SPAN&gt;This dataset includes a dynamic data source. Since dynamic data sources aren't refreshed in the Power BI service,"&lt;BR /&gt;&lt;/SPAN&gt;I had done some research and it seems I need to trick the PowerBI server into not treating this like a dynamic data source, possibly by moving the variable down to Web.contents - but cant get it to work.&lt;BR /&gt;&lt;BR /&gt;Current code is....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(projectIDVariabl) =&amp;gt;&lt;/P&gt;&lt;P&gt;let&lt;BR /&gt;url = "&lt;A href="https://api.workguru.io/api/ClientTokenAuth/Authenticate/api/client/v1/tokenauth" target="_blank" rel="noopener"&gt;https://api.workguru.io/api/ClientTokenAuth/Authenticate/api/client/v1/tokenauth&lt;/A&gt;",&lt;/P&gt;&lt;P&gt;body = "{ ""ApiKey"": ""XXX"", ""Secret"": ""XXX"" }",&lt;BR /&gt;tokenResponse = Json.Document(Web.Contents(url,[Headers = [#"Content-Type"="application/json"], Content = Text.ToBinary(body) ] )),&lt;BR /&gt;AccessToken = tokenResponse[accessToken],&lt;BR /&gt;AccessTokenHeader = "Bearer " &amp;amp; AccessToken,&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;data_url = "&lt;A href="https://api.workguru.io/api/services/app/Project/GetProjectById?id=" target="_blank" rel="noopener"&gt;https://api.workguru.io/api/services/app/Project/GetProjectById?id=&lt;/A&gt;&lt;FONT color="#FF0000"&gt;"&amp;amp; Number.ToText(projectIDVariabl)&amp;amp;"&lt;/FONT&gt;&amp;amp;includeProductImages=false&amp;amp;includeLineItemCustomFields=true",&lt;BR /&gt;data_body = "{&lt;BR /&gt;""authorization"": """&amp;amp; AccessTokenHeader &amp;amp; """,&lt;BR /&gt;""content-type"": ""application/json""&lt;BR /&gt;}",&lt;/P&gt;&lt;P&gt;GetGroups = Json.Document(&lt;BR /&gt;Web.Contents(&lt;BR /&gt;data_url,&lt;BR /&gt;[&lt;BR /&gt;Headers = Json.Document(data_body)&lt;BR /&gt;]&lt;BR /&gt;)&lt;BR /&gt;),&lt;BR /&gt;#"Converted to Table" = Record.ToTable(GetGroups),&lt;BR /&gt;Value1 = #"Converted to Table"{0}[Value],&lt;BR /&gt;#"Converted to Table1" = Record.ToTable(Value1),&lt;BR /&gt;#"Transposed Table" = Table.Transpose(#"Converted to Table1"),&lt;BR /&gt;#"Promoted Headers" = Table.PromoteHeaders(#"Transposed Table", [PromoteAllScalars=true]),&lt;BR /&gt;#"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"tenantId", Int64.Type}, {"projectNo", type text}, {"projectName", type text}, {"description", type text}, {"startDate", type datetime}, {"dueDate", type datetime}, {"clientId", Int64.Type}, {"billingClientId", Int64.Type}, {"projectGroupId", type any}, {"clientPurchaseOrder", type any}, {"status", type text}, {"warehouse", type any}, {"warehouseId", type any}, {"contactId", Int64.Type}, {"contact", type any}, {"billingClient", type any}, {"client", type any}, {"recurringProjectId", type any}, {"recurringProject", type any}, {"customFieldValues", type any}, {"invoices", type any}, {"timeSheets", type any}, {"notes", type any}, {"files", type any}, {"taskLineItems", type any}, {"productLineItems", type any}, {"milestones", type any}, {"stockUsage", type any}, {"clientCreditNotes", type any}, {"completedDate", type any}, {"asset", type any}, {"assetId", type any}, {"purchaseOrders", type any}, {"quoteId", type any}, {"quote", type any}, {"reportingCategoryOption1Id", Int64.Type}, {"reportingCategoryOption2Id", type any}, {"reportingCategoryOption1", type any}, {"reportingCategoryOption2", type any}, {"currency", type text}, {"exchangeRate", Int64.Type}, {"projectGroup", type any}, {"projectManagerId", Int64.Type}, {"projectManager", type any}, {"forecastTime", Int64.Type}, {"totalTime", Int64.Type}, {"total", Int64.Type}, {"baseCurrencyTotal", Int64.Type}, {"documentStorageId", type any}, {"externalSystemId", type any}, {"externalSystemWebhookKey", type any}, {"supplierCreditNotes", type any}, {"useStaffRates", type logical}, {"totalInvoiced", Int64.Type}, {"totalTax", Int64.Type}, {"cost", Int64.Type}, {"forecastCost", Int64.Type}, {"profit", Int64.Type}, {"profitPercentage", Int64.Type}, {"isProductionJob", type logical}, {"phases", type any}, {"customFieldGroupId", type any}, {"customFieldGroup", type any}, {"isDeleted", type logical}, {"deleterUserId", type any}, {"deletionTime", type any}, {"lastModificationTime", type any}, {"lastModifierUserId", type any}, {"creationTime", type datetime}, {"creatorUserId", Int64.Type}, {"id", Int64.Type}}),&lt;BR /&gt;#"Expanded customFieldValues" = Table.ExpandListColumn(#"Changed Type", "customFieldValues"),&lt;BR /&gt;#"Expanded customFieldValues1" = Table.ExpandRecordColumn(#"Expanded customFieldValues", "customFieldValues", {"customFieldId", "value"}, {"customFieldValues.customFieldId", "customFieldValues.value"}),&lt;BR /&gt;#"Filtered Rows" = Table.SelectRows(#"Expanded customFieldValues1", each ([customFieldValues.customFieldId] = 2199))&lt;BR /&gt;in&lt;BR /&gt;#"Filtered Rows"&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 20 May 2024 05:02:27 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Passing-Variables-into-API-URL-without-preventing-PBI-Server/m-p/3931206#M52662</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-05-20T05:02:27Z</dc:date>
    </item>
    <item>
      <title>Re: Passing Variables into API URL - without preventing PBI Server dataset refresh</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Passing-Variables-into-API-URL-without-preventing-PBI-Server/m-p/3933726#M52686</link>
      <description>&lt;P&gt;Hi&amp;nbsp;@Anonymous&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;Perhaps you can try to use option parameters in web connector if they help you to handle this scenario:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;let
    GetProejct=(projectID as number) =&amp;gt;
    let
        projectIDVariabl = projectID,
        root_url = "https://api.workguru.io",
        body = "{ ""ApiKey"": ""XXX"", ""Secret"": ""XXX"" }",
        tokenResponse = Web.Contents(
            root_url,
            [
                Headers = [#"Content-Type" = "application/json"],
                RelativePath = "/api/ClientTokenAuth/Authenticate/api/client/v1/tokenauth",
                Content = Text.ToBinary(body)
            ]
        ),
        AccessToken = Json.Document(tokenResponse)[accessToken],
        projectResponse = Web.Contents(
            root_url,
            [
                RelativePath = "/api/services/app/Project/GetProjectById",
                Headers = [#"content-type": "application/json", authorization = "Bearer " &amp;amp; AccessToken],
                Query = [
                    id = Number.ToText(projectIDVariabl),
                    includeProductImages = "false",
                    includeLineItemCustomFields = "true"
                ]
            ]
        ),
        GetGroups = Json.Document(projectResponse)
    in
        GetGroups
in 
    GetProejct&lt;/LI-CODE&gt;
&lt;P&gt;&lt;A href="https://blog.crossjoin.co.uk/2016/08/16/using-the-relativepath-and-query-options-with-web-contents-in-power-query-and-power-bi-m-code/" target="_blank"&gt;Chris Webb's BI Blog: Using The RelativePath And Query Options With Web.Contents() In Power Query And Power BI M Code (crossjoin.co.uk)&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://blog.crossjoin.co.uk/2021/01/10/handling-multiple-url-query-parameters-with-the-same-name-using-web-contents-in-power-query-power-bi/" target="_blank"&gt;Chris Webb's BI Blog: Handling Multiple URL Query Parameters With The Same Name Using Web.Contents In Power Query/Power BI (crossjoin.co.uk)&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Xiaoxin Sheng&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 May 2024 01:26:16 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Passing-Variables-into-API-URL-without-preventing-PBI-Server/m-p/3933726#M52686</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-05-21T01:26:16Z</dc:date>
    </item>
    <item>
      <title>Re: Passing Variables into API URL - without preventing PBI Server dataset refresh</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Passing-Variables-into-API-URL-without-preventing-PBI-Server/m-p/3940885#M52788</link>
      <description>&lt;P&gt;Thank you so much - that does the job nicely.&lt;BR /&gt;I just needed to update the colon to an equals in this line.&lt;/P&gt;&lt;PRE&gt; Headers = [#"content-type": "application/json", authorization = "Bearer " &amp;amp; AccessToken],&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 22 May 2024 22:32:52 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Passing-Variables-into-API-URL-without-preventing-PBI-Server/m-p/3940885#M52788</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-05-22T22:32:52Z</dc:date>
    </item>
  </channel>
</rss>

