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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
eduardosilvin3
Helper II
Helper II

REST API with POST method and Basic auth

Hello, I am trying to connect my POST method for a REST API from planful with a blank query in PQuery. I use the query (replacing endpoint, user and password):

let
    url = "https://xxxxx",
    body = Text.ToBinary("{ ""Scenario"": ""Actual"", ""FiscalYear"": 2024, ""FiscalMonth"": 6, ""top"": 100 }"), 
    headers = [
        #"Content-Type" = "application/json",  
        Authorization = "Basic " & Binary.ToText(Text.ToBinary("user:password"), BinaryEncoding.Base64) 
    ],
    response = Web.Contents(url, [
        Content = body,  
        Headers = headers,
        ManualStatusHandling = {400, 404, 405}  
    ]),
    jsonResponse = Json.Document(response)  
in
    jsonResponse

but I reveive always this error (compared in postman and working correctly):

DataSource.Error: Web.Contents with the Content option is only supported when connecting anonymously.
Details:
    DataSourceKind=Web
    DataSourcePath=https://xxxxxx

 

If I connect with the "Get Data" button selecting WEB, another API with Planful but GET Method and it works perfectly with the prompt window and then selecting Basic. But if I try the Post method I will receive this error:

Details: "Web.Contents failed to get contents from 'https://xxxxx' (405): Method Not Allowed"

 

Any help to get the data with post method? I've been trying a lot of things, chat gpt, but nothing seems to work.

Thanks in advance

 

1 ACCEPTED SOLUTION

Thanks for the response, but I've been trying with those codes in PQuery, but the problem mentioned in the post appear when I try to use Basic Auth in that Post method. What I've been reading is that PBI is selecting GET as default method and something Crash when you try to add Basic Auth in Post method. My current solution is using a Python script, test it in visual studio, and if that gives me the data I need, the Get Data source in PBI will be Python Scipt. that runs correctly, the only thing is that user and pswrd will be in the code, so you can create env variables in your pc or server, and avoid write them in the script. I will select this as solution in case after some more hours anyone have any other solution.

 

Thanks 😁

View solution in original post

2 REPLIES 2
lbendlin
Super User
Super User

Can you try with Json.FromValue instead?

 

Web.Contents - PowerQuery M | Microsoft Learn

Thanks for the response, but I've been trying with those codes in PQuery, but the problem mentioned in the post appear when I try to use Basic Auth in that Post method. What I've been reading is that PBI is selecting GET as default method and something Crash when you try to add Basic Auth in Post method. My current solution is using a Python script, test it in visual studio, and if that gives me the data I need, the Get Data source in PBI will be Python Scipt. that runs correctly, the only thing is that user and pswrd will be in the code, so you can create env variables in your pc or server, and avoid write them in the script. I will select this as solution in case after some more hours anyone have any other solution.

 

Thanks 😁

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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