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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

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
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

Users online (817)