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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
Syndicate_Admin
Administrator
Administrator

Web.Contents with the Content option is supported only when connecting anonymously.

Hello

I'm trying to connect to a data source using a POST request. To do this, I am creating a blank query that follows the following scheme:
Let
url = "",
body = "{}",

header = [#"Content-Type"="application/json", #"Authoritation" = "Basic xxxxxxxx"],
result = Json.Document(Web.Contents(url,[Headers = header, Content=Text.ToBinary(body)]))

in
result


Currently, you are giving the following error: Web.Contents with the Content option is only supported when connecting anonymously. How could I make a POST request that had body and basic authentication?

Thank you.

2 ACCEPTED SOLUTIONS
Anonymous
Not applicable

Hi @Anonymous ,

Here is the sample code(use token to login and get access token for following operations) about use anonymous mode authorization to get data from web connector, you can take a look on it if helps:

let
    url = "api.xxxx.com",
    body = "{}",
    token = "xxxxxxxx",
    header = [
        #"Content-Type" = "application/json",
        #"Authoritation" = "Basic " & token
    ],
    response = Web.Contents(url, [
        RelativePath = "/xxxx/login",
        Headers = header,
        Content = Text.ToBinary(body)
    ]),
    AccessToken = Json.Document(response)[access_token],
    JsonResponse = Web.Contents(
        url,
        [
            RelativePath = "/xxx/xxx",
            Headers = [
                Authoraztion = "Basic " & AccessToken,
                #"Content-Type" = "application/json"
            ]
        ]
    ),
    Result = Json.Document(JsonResponse)
in
    Result

Regards,

Xiaoxin Sheng

View solution in original post

Syndicate_Admin
Administrator
Administrator

Hello

Finally, I got it to work with the code I was providing. It would be necessary to pass the authentication method in the Header of the request and at the moment in which Power BI asks for the credentials, choose the option of "Anonymous". In this way, it connects correctly.

Thank you.



View solution in original post

3 REPLIES 3
Little-Mike
New Member

If you want to help, you should take care for correct spelling in your code sample: you write "Authoritation" and also "Authoraztion"...

Syndicate_Admin
Administrator
Administrator

Hello

Finally, I got it to work with the code I was providing. It would be necessary to pass the authentication method in the Header of the request and at the moment in which Power BI asks for the credentials, choose the option of "Anonymous". In this way, it connects correctly.

Thank you.



Anonymous
Not applicable

Hi @Anonymous ,

Here is the sample code(use token to login and get access token for following operations) about use anonymous mode authorization to get data from web connector, you can take a look on it if helps:

let
    url = "api.xxxx.com",
    body = "{}",
    token = "xxxxxxxx",
    header = [
        #"Content-Type" = "application/json",
        #"Authoritation" = "Basic " & token
    ],
    response = Web.Contents(url, [
        RelativePath = "/xxxx/login",
        Headers = header,
        Content = Text.ToBinary(body)
    ]),
    AccessToken = Json.Document(response)[access_token],
    JsonResponse = Web.Contents(
        url,
        [
            RelativePath = "/xxx/xxx",
            Headers = [
                Authoraztion = "Basic " & AccessToken,
                #"Content-Type" = "application/json"
            ]
        ]
    ),
    Result = Json.Document(JsonResponse)
in
    Result

Regards,

Xiaoxin Sheng

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors