<?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: API connection with headers renewing online? (Dyflexis) in Power Query</title>
    <link>https://community.fabric.microsoft.com/t5/Power-Query/API-connection-with-headers-renewing-online-Dyflexis/m-p/3780906#M124635</link>
    <description>&lt;P&gt;No need for the question mark if you don't have Query parameters.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Not clear what is behind the xxxxxx but if that is variable then you need to use RelativePath.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://learn.microsoft.com/en-us/powerquery-m/web-contents" target="_blank"&gt;Web.Contents - PowerQuery M | Microsoft Learn&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 20 Mar 2024 23:51:52 GMT</pubDate>
    <dc:creator>lbendlin</dc:creator>
    <dc:date>2024-03-20T23:51:52Z</dc:date>
    <item>
      <title>API connection with headers renewing online? (Dyflexis)</title>
      <link>https://community.fabric.microsoft.com/t5/Power-Query/API-connection-with-headers-renewing-online-Dyflexis/m-p/3780299#M124608</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm creating a report based on Dyflexis. to get data I have to connect to an API.&amp;nbsp;&lt;SPAN&gt;The API requires this headers:&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;Content&lt;SPAN class=""&gt;-&lt;/SPAN&gt;Type&lt;SPAN class=""&gt;:&lt;/SPAN&gt; application&lt;SPAN class=""&gt;/&lt;/SPAN&gt;json
Accept&lt;SPAN class=""&gt;:&lt;/SPAN&gt; application&lt;SPAN class=""&gt;/&lt;/SPAN&gt;json
Authorization&lt;SPAN class=""&gt;:&lt;/SPAN&gt; Token YOUR_AUTH_TOKEN&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;In desktop it works fine and I can refresh, but I can't refresh the data online. Is there a way to rewrite this M code, so that online refreshing is possible? This is the M-code for the Scheduled Shifts: (API description:&amp;nbsp;&lt;A href="https://developer.dyflexis.com/v3/#tag/Business-Intelligence/operation/Scheduled%20shifts" target="_blank" rel="noopener"&gt;https://developer.dyflexis.com/v3/#tag/Business-Intelligence/operation/Scheduled%20shifts )&lt;/A&gt;&lt;/SPAN&gt;&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
    BaseUrl = "https://app.planning.nu/xxxxx/api/business/v3/scheduled?",
    Token = "xxxxx",

    GetJson = (Url) =&amp;gt;
        let
            Options = [
                Headers = [
                    Accept = "application/json",
                    #"Content-Type" = "application/json",
                    #"Authorization" = "Token " &amp;amp; Token
                ]
            ],
            RawData = Web.Contents(Url, Options),
            Json = Json.Document(RawData)
        in
            Json,

    GetShifts = (PageNumber) =&amp;gt;
        let
            Url = BaseUrl &amp;amp; "page=" &amp;amp; Text.From(PageNumber),
            Json = GetJson(Url),
            Shifts = Json[shifts]
        in
            Shifts,

    PageCount = try GetJson(BaseUrl &amp;amp; "$count=true&amp;amp;$top=0")[pageCount] otherwise 1,

    Pages = List.Transform({1..PageCount}, each GetShifts(_)),
    Table = Table.FromList(List.Combine(Pages), Splitter.SplitByNothing(), null, null, ExtraValues.Error),
    #"Expanded Column1" = Table.ExpandRecordColumn(Table, "Column1", {"id", "employeeId", "personnelNumber", "firstName", "infix", "lastName", "officeId", "officeName", "departmentId", "departmentName", "costCenterId", "costCenterName", "costCenterCode", "startDateTime", "endDateTime", "breakMinutes", "duration", "remark", "marking"}, {"id", "employeeId", "personnelNumber", "firstName", "infix", "lastName", "officeId", "officeName", "departmentId", "departmentName", "costCenterId", "costCenterName", "costCenterCode", "startDateTime", "endDateTime", "breakMinutes", "duration", "remark", "marking"}),
    #"Changed Type" = Table.TransformColumnTypes(#"Expanded Column1",{{"startDateTime", type datetime}, {"endDateTime", type datetime}, {"id", Int64.Type}, {"employeeId", Int64.Type}, {"personnelNumber", Int64.Type}}),
    #"Changed Type1" = Table.TransformColumnTypes(#"Changed Type",{{"startDateTime", type date}})
in
    #"Changed Type1"&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;Or is there another way to do this?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Jelle&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Mar 2024 18:04:03 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Power-Query/API-connection-with-headers-renewing-online-Dyflexis/m-p/3780299#M124608</guid>
      <dc:creator>jelleschuurman</dc:creator>
      <dc:date>2024-03-20T18:04:03Z</dc:date>
    </item>
    <item>
      <title>Re: API connection with headers renewing online? (Dyflexis)</title>
      <link>https://community.fabric.microsoft.com/t5/Power-Query/API-connection-with-headers-renewing-online-Dyflexis/m-p/3780906#M124635</link>
      <description>&lt;P&gt;No need for the question mark if you don't have Query parameters.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Not clear what is behind the xxxxxx but if that is variable then you need to use RelativePath.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://learn.microsoft.com/en-us/powerquery-m/web-contents" target="_blank"&gt;Web.Contents - PowerQuery M | Microsoft Learn&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Mar 2024 23:51:52 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Power-Query/API-connection-with-headers-renewing-online-Dyflexis/m-p/3780906#M124635</guid>
      <dc:creator>lbendlin</dc:creator>
      <dc:date>2024-03-20T23:51:52Z</dc:date>
    </item>
    <item>
      <title>Re: API connection with headers renewing online? (Dyflexis)</title>
      <link>https://community.fabric.microsoft.com/t5/Power-Query/API-connection-with-headers-renewing-online-Dyflexis/m-p/3781926#M124668</link>
      <description>&lt;P&gt;The xxxxx is our organisationname, static.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I remove the questionmark, I get this error:&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;DataSource.Error: Web.Contents failed to get contents from 'https://app.planning.nu/xxxxx/api/business/v3/scheduled$count=true&amp;amp;$top=0' (404): Not Found
Details:
DataSourceKind=Web
DataSourcePath=https://app.planning.nu/xxxxx/api/business/v3/scheduled$count=true&amp;amp;$top=0
Url=https://app.planning.nu/xxxxx/api/business/v3/scheduled$count=true&amp;amp;$top=0&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Mar 2024 07:59:55 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Power-Query/API-connection-with-headers-renewing-online-Dyflexis/m-p/3781926#M124668</guid>
      <dc:creator>jelleschuurman</dc:creator>
      <dc:date>2024-03-21T07:59:55Z</dc:date>
    </item>
    <item>
      <title>Re: API connection with headers renewing online? (Dyflexis)</title>
      <link>https://community.fabric.microsoft.com/t5/Power-Query/API-connection-with-headers-renewing-online-Dyflexis/m-p/3783901#M124742</link>
      <description>&lt;P&gt;Show the Power Query code.&amp;nbsp; Make sure to use both RelativePath and Query.&lt;/P&gt;</description>
      <pubDate>Thu, 21 Mar 2024 19:08:49 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Power-Query/API-connection-with-headers-renewing-online-Dyflexis/m-p/3783901#M124742</guid>
      <dc:creator>lbendlin</dc:creator>
      <dc:date>2024-03-21T19:08:49Z</dc:date>
    </item>
  </channel>
</rss>

