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
Asynchronism
Frequent Visitor

REST API returning JSON data

Hi All,

 

I have a REST API that returns JSON formatted data.

 

Here's what's in Power Query Advanced Editor:

 

let

bodytext =
"{""StartDate"":""2018-01-01"",
""EndDate"":""2019-12-31""}",
url = "<removed>",
body = Json.FromValue(bodytext),

 

Source =
Json.Document(
(Web.Contents

(url
, [Headers=
[#"Content-Type"="application/json"
,Authorization="aaaaa"
, Key="1234"
, Value="1234"],

Content = body])))
in
Source

 

I'm getting a "(405): Method Not Allowed" back.   I believe it's at the Content = body line.

 

Everything is working in PostMan.  Authorization, Key, Value all are parameters, and I'm passing StartDate and EndDate in the body.

 

Appreciate any input, I've got about 5 hours into debugging... first time trying this here!

 

1 ACCEPTED SOLUTION
blopez11
Super User
Super User

If you include the content parameter to web.contents, I believe it forces an HTTP POST method.  Is this what you are expecting?  Also, in my past experience I've always used Text.ToBinary where you are using Json.FromValue

View solution in original post

3 REPLIES 3
blopez11
Super User
Super User

If you include the content parameter to web.contents, I believe it forces an HTTP POST method.  Is this what you are expecting?  Also, in my past experience I've always used Text.ToBinary where you are using Json.FromValue

Anonymous
Not applicable

I Need To connect an API on power bi with the TOKEN and the Headers, someone can help me?

I think you're right about the post, will keep trying to debug it.  Thanks!

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.