Warm tip: This article is reproduced from stackoverflow.com, please click
powerbi

Power BI DataSource.Error: Web.Contents failed to get contents from url error?

发布于 2020-04-23 15:13:11

Recently my Power BI dashboard has started to return an error and I'm not sure why. Can anyone explain why it might have failed?

The error I'm getting is:

DataSource Error

The Advanced Query I'm using is:

let
    url = "http://<domain>:<port>/jderest/orchestrator/SEF_ORCH_V4211APBISalesDash",
    body = "{""deviceName"":""PowerBI"",""username"":""<username>"",""password"":""<password>""}",
    Source = Json.Document(Web.Contents(url, [Headers=[ContentType="application/json"],Content = Text.ToBinary(body)]))
in
    Source

I'm not sure what's wrong with it. I tried running it via Soup UI with the above and it worked.

enter image description here

Can anyone explain why the Advanced Query is erroring?

Questioner
Flip7607
Viewed
126
Flip7607 2020-02-11 23:19

We found the solution. It looks like it stemmed from a newer update.

What was wrong is ContentType="application/json" in the headers needed to have it's format updated. The correct format is #"Content-Type"="application/json".

So the original code:

let
    url = "http://<domain>:<port>/jderest/orchestrator/SEF_ORCH_V4211APBISalesDash",
    body = "{""deviceName"":""PowerBI"",""username"":""<username>"",""password"":""<password>""}",
    Source = Json.Document(Web.Contents(url, [Headers=[ContentType="application/json"],Content = Text.ToBinary(body)]))
in
    Source

Needed to be:

let
    url = "http://<domain>:<port>/jderest/orchestrator/SEF_ORCH_V4211APBISalesDash",
    body = "{""deviceName"":""PowerBI"",""username"":""<username>"",""password"":""<password>""}",
    Source = Json.Document(Web.Contents(url, [Headers=[#"Content-Type"="application/json"],Content = Text.ToBinary(body)]))
in
    Source

The reason for this is because after an update (not sure which one) ContentType="application/json" was treated as a miscellaneous tag

enter image description here

With the change to #"Content-Type"="application/json" It was no longer a miscellaneous tag. It is treated as an entity like before.

enter image description here