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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
TK12345
Resolver I
Resolver I

Web.Contents - we couldn't authenticate with the credentials provided (using anonymous credentials)

Hi guys, I need help with the following issue, I am trying to connect with an API with a "next" on the end of the page, this next contains a new URL that gives us the next page, I need to loop this in Power BI until I have all the data. The point is, I get the following error while I am using the right credentials: 

Web.Contents - we couldn't authenticate with the credentials provided (using anonymous credentials)

I am trying the following:

(baseuri as text) =>

let

    headers = [Headers=[Accept="application/json", Authorization="Basic xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"]],

 

    initReq = Json.Document(Web.Contents(baseuri, headers)),

    initData = initReq[data],

    //We want to get data = {lastNPagesData, thisPageData}, where each list has the limit # of Records,

    //then we can List.Combine() the two lists on each iteration to aggregate all the records. We can then

    //create a table from those records

    gather = (data as list, uri) =>

        let

            //get new offset from active uri

            newOffset = Json.Document(Web.Contents(uri, headers))[next],

            //build new uri using the original uri so we dont append offsests

            newUri = newOffset,

            //get new req & data

            newReq = Json.Document(Web.Contents(newUri, headers)),

            newdata = newReq[data],

            //add that data to rolling aggregate

            data = List.Combine({data, newdata}),

            //if theres no next page of data, return. if there is, call @gather again to get more data

            check = if newReq[next_page] = null then data else @gather(data, newUri)

        in check,

    //before we call gather(), we want see if its even necesarry. First request returns only one page? Return.

    outputList = if initReq[next_page] = null then initData else gather(initData, baseuri),

    //then place records into a table. This will expand all columns available in the record.

    expand = Table.FromRecords(outputList)

in

    expand


I first received the error that the datasource needs to be anonymously, changing that brings me this error. How do I need to solve this? 

 

2 REPLIES 2
lbendlin
Super User
Super User

Are you maybe supposed to provide a session id for subsequent calls?  Check the documentation of the API you are accessing.

Hi @lbendlin,

Thanks for your reply, 
Unfortunately that is not the case. It is all based on the url at the end of the page and the authorization. 

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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