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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Anonymous
Not applicable

power query 400 bad request

I have a power query like this, and it gives me this 400 bad request error when I try to exec it. Any help would be appreciated.

 

 

let
    content = "{
    ""spec"": {
        ""ids"": [""0001""],
        ""interval"":""HOUR"",
        ""expressions"": [
            ""CompoundChilledWaterConsumptionForecast""
        ],
        ""start"": ""2020-01-01T00:00:00.000"",
        ""end"": ""2020-01-02T09:00:00.000"",
        ""include"": ""start, end, interval, count, dates, data, timeZone, unit""
        }
    }",
    Source = Json.Document(Web.Contents("https://engie-osep.c3iot.com/api/1/engie-osep/prod/Facility?action=evalMetrics", [Headers=[#"Authorization"="Basic xxxxxxx"]]))
in
    Source

 

 

1 ACCEPTED SOLUTION
v-lid-msft
Community Support
Community Support

Hi @Anonymous ,

 

It seems you want to post a request, we need to ues Contens record in Web.Contents as following:

 

let
    ContentBody = "{
    ""spec"": {
        ""ids"": [""0001""],
        ""interval"":""HOUR"",
        ""expressions"": [
            ""CompoundChilledWaterConsumptionForecast""
        ],
        ""start"": ""2020-01-01T00:00:00.000"",
        ""end"": ""2020-01-02T09:00:00.000"",
        ""include"": ""start, end, interval, count, dates, data, timeZone, unit""
        }
    }",
    Source = Json.Document(Web.Contents("https://URL/api/1/engie-osep/prod/Facility?action=evalMetrics", [Headers=[#"Authorization"="Basic xxxxxxx"], Contens=ContentBody]))
in
    Source

 

Please refer to following document about Web.Contents function:

https://docs.microsoft.com/en-us/powerquery-m/web-contents


Best regards,

 

Community Support Team _ Dong Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-lid-msft
Community Support
Community Support

Hi @Anonymous ,

 

It seems you want to post a request, we need to ues Contens record in Web.Contents as following:

 

let
    ContentBody = "{
    ""spec"": {
        ""ids"": [""0001""],
        ""interval"":""HOUR"",
        ""expressions"": [
            ""CompoundChilledWaterConsumptionForecast""
        ],
        ""start"": ""2020-01-01T00:00:00.000"",
        ""end"": ""2020-01-02T09:00:00.000"",
        ""include"": ""start, end, interval, count, dates, data, timeZone, unit""
        }
    }",
    Source = Json.Document(Web.Contents("https://URL/api/1/engie-osep/prod/Facility?action=evalMetrics", [Headers=[#"Authorization"="Basic xxxxxxx"], Contens=ContentBody]))
in
    Source

 

Please refer to following document about Web.Contents function:

https://docs.microsoft.com/en-us/powerquery-m/web-contents


Best regards,

 

Community Support Team _ Dong Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Greg_Deckler
Community Champion
Community Champion

Well,

 

The 400 Bad Request error is an HTTP status code that means that the request you sent to the website server, often something simple like a request to load a web page, was somehow incorrect or corrupted and the server couldn't understand it.

 

I imagine it has something to do with the Headers you are sending.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors
Top Kudoed Authors