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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
kalspiros
Helper I
Helper I

JSON and authentication issues

Hi all,

 

Following multiple attempts and researches, the problem persists.

I am trying to connect to a business management system and i constantly have issues with authorisation.

This is what i use (Example 2🙂

 

let
    apiToken = "********************************",
    url = "https://********.**********.com/api/tasks",
    query = [
        start = "2022-01-01",
        end = "2022-01-31"
    ],
    headers = [
        Authorization = "Token " & apiToken,
        #"Content-Type" = "application/json"
    ],
    response = Web.Contents(
        url,
        [
            Headers = headers,
            Query = query
        ]
    ),
    jsonResponse = Json.Document(response)
in
    jsonResponse

 

  and that is what i get

kalspiros_0-1650888691762.png

i changed to anonymous

kalspiros_1-1650888985113.png

and getting this one

kalspiros_2-1650889101795.png

 

Then i have tried this version which i found here:

 

let
    apiToken = "************************",
    site = "https://****.*********.com/",
    url = "api/tasks",
    query = [
        start = "2022-01-01",
        end = "2022-01-31"
    ],
    headers = [
        Authorization = "Token " & apiToken,
        #"Content-Type" = "application/json"
    ],
    response = Web.Contents(
        site,
        [
                RelativePath = url,
            Headers = headers,
            Query = query
        ]
    ),
    jsonResponse = Json.Document(response)
in
    jsonResponse

 

 and i'm still getting the same authentication errors.

 

Can anyone spot an issue with the code? could it be the actual API having issues?

 

Many thanks!

1 ACCEPTED SOLUTION

Many thanks @Anonymous even though, in the end, i used anonymous. my mistake was that i was using the entire API address in the level where i should have only used the link to the site.

 

Have another concern now. Protecting the API Token. Currently reading this one https://community.powerbi.com/t5/Developer/Protection-of-API-Keys-Stored-in-Parameter/m-p/1564020

and i'll keep searching.

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @kalspiros ,

 

To my knowledge, since you have such header:

 Authorization = "Token " & apiToken

The data source requires credentials, so Anonymous is not applicable. Please try other authentication methods instead :

  • Anonymous: Select this authentication method if the web page doesn't require any credentials.

  • Windows: Select this authentication method if the web page requires your Windows credentials.

  • Basic: Select this authentication method if the web page requires a basic user name and password.

  • Web API: Select this method if the web resource that you’re connecting to uses an API Key for authentication purposes.

  • Organizational account: Select this authentication method if the web page requires organizational account credentials.

 

Refer to:

Power Query Web connector - Power Query | Microsoft Docs

Solved: Re: Pull data from RESTful API with token authenti... - Microsoft Power BI Community

 

 

Best Regards,
Eyelyn Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Many thanks @Anonymous even though, in the end, i used anonymous. my mistake was that i was using the entire API address in the level where i should have only used the link to the site.

 

Have another concern now. Protecting the API Token. Currently reading this one https://community.powerbi.com/t5/Developer/Protection-of-API-Keys-Stored-in-Parameter/m-p/1564020

and i'll keep searching.

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

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.