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

Data Days is here! Join us now for 60+ days of learning, challenges, and connection. Learn more

Reply
michael_mcclari
Regular Visitor

Unable to do basic authentication with function

Hello, i am having trouble doing basic authentication within a function. Please see my code below:

 

GetData

(page as number) as table =>
let
    Source = Web.Page(Web.Contents("https://my_company.atlassian.net/rest/api/2/search?jql=created%20%3E%20startOfMonth()&maxResults=100&startAt=" & Number.ToText(page) & "00")),
    Data1 = Source{1}[Data],
    RemoveBottom = Table.RemoveLastN(Data1,3)
in
    Data1

The funny thing is that I have no trouble doing basic authentication with the exact same URL in another query that uses this function, except when it calls the function.

 

Page

let
    url = "https://my_company.atlassian.net/rest/api/2/search?jql=created%20%3E%20startOfMonth()&maxResults=100",
    query = Json.Document(Web.Contents(url)),
    total = query[total],
    maxResults = query[maxResults],
    N = total / maxResults,
    M = Number.RoundDown(N),
    Source = {1..M},
    ToTable = Table.FromList(Source, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
    Renamed = Table.RenameColumns(ToTable,{{"Column1", "Page"}}),

    //Everything works fine including authentication to "url" on line 2 but fails when it calls "GetData" on the next line
    Added = Table.AddColumn(Renamed, "Custom", each GetData([Page]))
in
    Added

Seems Basic Authentication works differently when in a function.

 

Any assistance would be greatly apprecaiated.

 

Regards,

Mike

1 REPLY 1
lightw0rks
Frequent Visitor

Having the same problem. Does anyone know why Basic Authentication fails when WebContents is called within a function?

Helpful resources

Announcements
Fabric Data Days is here Carousel

Fabric Data Days 2026

Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.

May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.