<?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: Add dynamic dates in API Source url in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/Add-dynamic-dates-in-API-Source-url/m-p/4017533#M53804</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sorry for the late reply.&lt;BR /&gt;&lt;BR /&gt;My input:&amp;nbsp;&lt;/P&gt;&lt;P&gt;let&lt;BR /&gt;EndDate= DateTime.LocalNow(),&lt;BR /&gt;StartDate = Date.AddMonths(DateTime.Date(EndDate), -3),&lt;BR /&gt;DateStart = DateTime.ToText(StartDate, "dd/mm/yyyy"),&lt;BR /&gt;DateEnd = DateTime.ToText(Today, "dd/mm/yyyy"),&lt;BR /&gt;apiUrl = "&lt;A href="https://xyz.com.au/api/" target="_blank"&gt;https://xyz.com.au/api/&lt;/A&gt;",&lt;BR /&gt;Source = Json.Document(Web.Contents(apiUrl,&lt;BR /&gt;[&lt;BR /&gt;Query = [&lt;BR /&gt;dbtable = "statementitems",&lt;BR /&gt;fundingtype = "2",&lt;BR /&gt;DateStart = DateStart,&lt;BR /&gt;DateEnd = DateEnd,&lt;BR /&gt;Authkey = ApiKey,&lt;BR /&gt;includedeleted = "yes",&lt;BR /&gt;toprestrict = "1000000",&lt;BR /&gt;source = "powerBI"&lt;BR /&gt;]&lt;BR /&gt;]&lt;BR /&gt;))&lt;BR /&gt;in&lt;BR /&gt;Source&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am getting this message&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="DryMouse555_0-1719801271816.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/1124529i75F1467934FF8E4C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="DryMouse555_0-1719801271816.png" alt="DryMouse555_0-1719801271816.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 01 Jul 2024 02:35:08 GMT</pubDate>
    <dc:creator>DryMouse555</dc:creator>
    <dc:date>2024-07-01T02:35:08Z</dc:date>
    <item>
      <title>Add dynamic dates in API Source url</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Add-dynamic-dates-in-API-Source-url/m-p/4014293#M53764</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have connected to a online system using API url and Auth key. Below is my code. This I enter in the blank query as source step.&lt;BR /&gt;&lt;BR /&gt;= Json.Document(Web.Contents("&lt;A href="https://xyz.com.au/api/" target="_blank"&gt;https://xyz.com.au/api/&lt;/A&gt;",&lt;BR /&gt;[Query=[&lt;BR /&gt;dbtable="statementitems",&lt;BR /&gt;fundingtype= "2",&lt;BR /&gt;&lt;STRONG&gt;DateStart = "Date.IsInPreviousMonth",&lt;/STRONG&gt;&lt;BR /&gt;DateEnd = "Date.IsInCurrentDay",&lt;BR /&gt;Authkey = ApiKey,&lt;BR /&gt;includedeleted = "yes",&lt;BR /&gt;toprestrict = "1000000",&lt;BR /&gt;source= "powerBI"&lt;BR /&gt;]]&lt;BR /&gt;))&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;I want to add in DateStart where whenever it refreshed, it pulls the last 3 months data and DateEnd to Current day.&lt;BR /&gt;Can you tell me how to do that? Thanks in advance.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jun 2024 23:37:25 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Add-dynamic-dates-in-API-Source-url/m-p/4014293#M53764</guid>
      <dc:creator>DryMouse555</dc:creator>
      <dc:date>2024-06-27T23:37:25Z</dc:date>
    </item>
    <item>
      <title>Re: Add dynamic dates in API Source url</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Add-dynamic-dates-in-API-Source-url/m-p/4014560#M53770</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/740392"&gt;@DryMouse555&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;To dynamically set the 'DateStart' to pull data from the last 3 months and 'DateEnd' to the current day in your API call, please modify the codes as below and check if it can work:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://learn.microsoft.com/en-us/powerquery-m/date-addmonths" target="_blank"&gt;Date.AddMonths - PowerQuery M | Microsoft Learn&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;let
    EndDate= DateTime.LocalNow(),
    StartDate = Date.AddMonths(DateTime.Date(EndDate), -3),
    DateStart = DateTime.ToText(StartDate, "yyyy-MM-dd"),
    DateEnd = DateTime.ToText(Today, "yyyy-MM-dd"),
    apiUrl = "https://xyz.com.au/api/",
    Source = Json.Document(Web.Contents(apiUrl,
        [
            Query = [
                dbtable = "statementitems",
                fundingtype = "2",
                DateStart = DateStart,
                DateEnd = DateEnd,
                Authkey = ApiKey,
                includedeleted = "yes",
                toprestrict = "1000000",
                source = "powerBI"
            ]
        ]
    ))
in
    Source&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards&lt;/P&gt;</description>
      <pubDate>Fri, 28 Jun 2024 02:46:13 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Add-dynamic-dates-in-API-Source-url/m-p/4014560#M53770</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-06-28T02:46:13Z</dc:date>
    </item>
    <item>
      <title>Re: Add dynamic dates in API Source url</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Add-dynamic-dates-in-API-Source-url/m-p/4017533#M53804</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sorry for the late reply.&lt;BR /&gt;&lt;BR /&gt;My input:&amp;nbsp;&lt;/P&gt;&lt;P&gt;let&lt;BR /&gt;EndDate= DateTime.LocalNow(),&lt;BR /&gt;StartDate = Date.AddMonths(DateTime.Date(EndDate), -3),&lt;BR /&gt;DateStart = DateTime.ToText(StartDate, "dd/mm/yyyy"),&lt;BR /&gt;DateEnd = DateTime.ToText(Today, "dd/mm/yyyy"),&lt;BR /&gt;apiUrl = "&lt;A href="https://xyz.com.au/api/" target="_blank"&gt;https://xyz.com.au/api/&lt;/A&gt;",&lt;BR /&gt;Source = Json.Document(Web.Contents(apiUrl,&lt;BR /&gt;[&lt;BR /&gt;Query = [&lt;BR /&gt;dbtable = "statementitems",&lt;BR /&gt;fundingtype = "2",&lt;BR /&gt;DateStart = DateStart,&lt;BR /&gt;DateEnd = DateEnd,&lt;BR /&gt;Authkey = ApiKey,&lt;BR /&gt;includedeleted = "yes",&lt;BR /&gt;toprestrict = "1000000",&lt;BR /&gt;source = "powerBI"&lt;BR /&gt;]&lt;BR /&gt;]&lt;BR /&gt;))&lt;BR /&gt;in&lt;BR /&gt;Source&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am getting this message&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="DryMouse555_0-1719801271816.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/1124529i75F1467934FF8E4C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="DryMouse555_0-1719801271816.png" alt="DryMouse555_0-1719801271816.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 01 Jul 2024 02:35:08 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Add-dynamic-dates-in-API-Source-url/m-p/4017533#M53804</guid>
      <dc:creator>DryMouse555</dc:creator>
      <dc:date>2024-07-01T02:35:08Z</dc:date>
    </item>
    <item>
      <title>Re: Add dynamic dates in API Source url</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Add-dynamic-dates-in-API-Source-url/m-p/4017880#M53810</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/740392"&gt;@DryMouse555&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;Base on the error message in the screenshot, it seems &lt;SPAN&gt;that there’s an issue with the date format or conversion. Please update the codes as below and check if it can return the expected data...&lt;/SPAN&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;let
    EndDate= DateTime.LocalNow(),
    StartDate = Date.AddMonths(DateTime.Date(EndDate), -3),
    DateStart = Date.ToText(StartDate, "yyyy-MM-dd"),
    DateEnd = Date.ToText(DateTime.Date(EndDate), "yyyy-MM-dd"),
    apiUrl = "https://xyz.com.au/api/",
    Source = Json.Document(Web.Contents(apiUrl,
    [
        Query = [
            dbtable = "statementitems",
            fundingtype = "2",
            DateStart = DateStart,
            DateEnd = DateEnd,
            Authkey = ApiKey,
            includedeleted = "yes",
            toprestrict = "1000000",
            source = "powerBI"
        ]
    ]
    ))
in
    Source&lt;/LI-CODE&gt;
&lt;P&gt;Best Regards&lt;/P&gt;</description>
      <pubDate>Mon, 01 Jul 2024 06:25:13 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Add-dynamic-dates-in-API-Source-url/m-p/4017880#M53810</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-07-01T06:25:13Z</dc:date>
    </item>
    <item>
      <title>Re: Add dynamic dates in API Source url</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Add-dynamic-dates-in-API-Source-url/m-p/4019277#M53832</link>
      <description>&lt;P&gt;Hi, I am still getting these errors. I have added the code above.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="DryMouse555_0-1719877205464.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/1125052iC79DF92F645C8F15/image-size/medium?v=v2&amp;amp;px=400" role="button" title="DryMouse555_0-1719877205464.png" alt="DryMouse555_0-1719877205464.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="DryMouse555_1-1719877229059.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/1125053i376D4E54EAA01192/image-size/medium?v=v2&amp;amp;px=400" role="button" title="DryMouse555_1-1719877229059.png" alt="DryMouse555_1-1719877229059.png" /&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;Also, before I put static date values, I used this code. I was told to use this date format to get the output&lt;/P&gt;&lt;P&gt;= Json.Document(Web.Contents("&lt;A href="https://xyz.com.au/api/" target="_blank"&gt;https://xyz.com.au/api/&lt;/A&gt;",&lt;BR /&gt;[Query=[&lt;BR /&gt;dbtable="statementitems",&lt;BR /&gt;fundingtype= "2",&lt;BR /&gt;DateStart = "01/Jun/2024",&lt;BR /&gt;Date.End = "29/Jun/2024",&lt;BR /&gt;Authkey = ApiKey,&lt;BR /&gt;includedeleted = "yes",&lt;BR /&gt;toprestrict = "1000000",&lt;BR /&gt;source= "powerBI"&lt;BR /&gt;]]&lt;BR /&gt;))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 01 Jul 2024 23:45:04 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Add-dynamic-dates-in-API-Source-url/m-p/4019277#M53832</guid>
      <dc:creator>DryMouse555</dc:creator>
      <dc:date>2024-07-01T23:45:04Z</dc:date>
    </item>
    <item>
      <title>Re: Add dynamic dates in API Source url</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Add-dynamic-dates-in-API-Source-url/m-p/4019697#M53835</link>
      <description>&lt;P&gt;Hi, I am still getting these errors. I have added the code above.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="DryMouse555_0-1719899050576.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/1125220iC5A65AF1CD0D52D6/image-size/medium?v=v2&amp;amp;px=400" role="button" title="DryMouse555_0-1719899050576.png" alt="DryMouse555_0-1719899050576.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="DryMouse555_1-1719899050573.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/1125221iBB3B94684DF002A6/image-size/medium?v=v2&amp;amp;px=400" role="button" title="DryMouse555_1-1719899050573.png" alt="DryMouse555_1-1719899050573.png" /&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;P&gt;Also, before I put static date values, I used this code. I was told to use this date format to get the output&lt;/P&gt;&lt;P&gt;= Json.Document(Web.Contents("&lt;A href="https://xyz.com.au/api/" target="_blank" rel="nofollow noopener noreferrer"&gt;https://xyz.com.au/api/&lt;/A&gt;",&lt;BR /&gt;[Query=[&lt;BR /&gt;dbtable="statementitems",&lt;BR /&gt;fundingtype= "2",&lt;BR /&gt;DateStart = "01/Jun/2024",&lt;BR /&gt;Date.End = "29/Jun/2024",&lt;BR /&gt;Authkey = ApiKey,&lt;BR /&gt;includedeleted = "yes",&lt;BR /&gt;toprestrict = "1000000",&lt;BR /&gt;source= "powerBI"&lt;BR /&gt;]]&lt;BR /&gt;))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Jul 2024 05:44:16 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Add-dynamic-dates-in-API-Source-url/m-p/4019697#M53835</guid>
      <dc:creator>DryMouse555</dc:creator>
      <dc:date>2024-07-02T05:44:16Z</dc:date>
    </item>
  </channel>
</rss>

