Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago

Rest Api and Parameter for current date

Hello,

 

I have a Rest Api with a date filter for a query. Last I had to change the date everyday to get the new data for the current date. So I started to write a  parameter which gives me the current date and put it in the soruce. The Parameter works and I get the right data but when  I save and close the Queries I geht this answer: 

 

Can someone help me to fix the problem?

 

 

here is my Code: 

 
let
  //Create a query parameter for today's date
 today = DateTime.Date(DateTime.LocalNow()),
  // Convert the date to the desired text format for the filter
  todayFilter = Date.ToText(today, "yyyy-MM-dd"),
  // Replace the date in the existing filter set with today's date
  newFilter = "filter[0][property]=orderTime&filter[0][expression]=>=&filter[0][value]=" & todayFilter,
  // Combining the URL and the new filter
  urlwithFilter = "Soruce?" & newFilter,
  // Get the data from the URL with the new filter
  Quelle = Json.Document(Web.Contents(urlwithFilter)),

 

 

 

2 Replies

    • Anonymous's avatar
      Anonymous
      Not applicable

      thank you. Now I can save and close my query. But I have a new problem that I can't refresh. 

      I get this response: 

       

      Requested on,Dataflow name,Dataflow refresh status,Table name,Partition name,Refresh status,Start time,End time,Duration,Rows processed,Bytes processed (KB),Max commit (KB),Processor Time,Wait time,Compute engine,Error,
      2023-03-08 12:19:17,M4M,Failed,Rest Api,NA,Failed,2023-03-08 12:19:17,2023-03-08 12:19:18,00:00:00.6240,NA,NA,NA,NA,NA,NA,Error: The current operation was canceled because one or more operations failed..  Request ID: d4a58d3e-4f34-c3eb-86ed-24fdc03e6117.
      2023-03-08 12:19:17,M4M,Failed,Rest Api mit Parameter,NA,Failed,2023-03-08 12:19:17,2023-03-08 12:19:18,00:00:00.5300,NA,NA,NA,NA,NA,NA,Error: Credentials not found for data source '<ccon>{"Kind":"Web" "Path":"source" "NormalizedPath":"source "IsDefaultForKind":false}</ccon>'.. Param1 = <ccon>{"Kind":"Web" "Path":"source" "NormalizedPath":"source" "IsDefaultForKind":false}</ccon> Request ID: d4a58d3e-4f34-c3eb-86ed-24fdc03e6117.