Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

API call Function with 2 dynamic arguments

I am attempting to use a function to iterate through 1 list and 1 column to perform an api call.

The function looks like this:

 

(agentID as text,
dayDate2 as date) as table =>
let
    Source = Xml.Tables(Web.Contents("https://api.url.com/api/stats/agents/"& agentID &"/statistics?d=" & Date.ToText(#date(Date.Year(dayDate2),Date.Month(dayDate2),Date.Day(dayDate2)),"yyyy-MM-dd"))),
    Table0 = Source{0}[Table]

in
    #"Table0"

The table calling the function looks like this:

let
    DateRange= List.Dates(#date(2019,01,01),365,#duration(1,0,0,0)),
    agentID = #"agent-id",
    Source = List.Transform(DateRange, each try {(_),  #"2Params"(List.Transform(agentID,each _),_)} otherwise null),
    Table0 = Source{0}[Table]



 
in
    #"Table0"

I've tried a bunch of iterations and different ways to get both parameters to the function but cannot seem to do so.

 

Any suggestions would be helpful.

 

Thank you 

2 REPLIES 2
v-frfei-msft
Community Support
Community Support

Hi @Anonymous ,

 

How about changing the code as below? 

(agentID as text,
dayDate2 as date) as table =>
let
    Source = Xml.Tables(Web.Contents("https://api.url.com/api/stats/agents/"& agentID &"/statistics?d=" & Date.ToText(#date(Date.Year(&dayDate2),Date.Month(&dayDate2),Date.Day(&dayDate2)),"yyyy-MM-dd"))),
    Table0 = Source{0}[Table]

in
    #"Table0"

 

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.
Anonymous
Not applicable

 

Unfortunately, it is not allowing me to enter that in the advanced editor, returning the error "expecting token literal"

 

I was under the assumption the issue is with my 'agent-id' list and how I am parsing it.

 

here is the associated error I am getting - 

 

Expression.Error: We cannot apply field access to the type List.
Details:
    Value=List
    Key=Table

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.