PowerBI DataSource.Error: Web.Contents failed to get contents (400): Bad request

PowerBI DataSource.Error: Web.Contents failed to get contents (400): Bad request

我在尝试发出 POST 请求时总是收到以下错误:

DataSource.Error: Web.Contents failed to get contents from 'http://3.93.175.1/api/abfrage/' (400): Bad Request 
Details:
DataSourceKind=Web
DataSourcePath=http://3.93.175.1/api/abfrage
Url=http://3.93.175.1/api/abfrage/

我的查询如下:

let
Source = Json.Document(Web.Contents("http://3.93.175.1/api/abfrage/", [Headers=[#"Content-Type"="application/json", Authorization="Token d04b033d7fa9760147aa32743284ace16de2bbd0"], Content=Json.FromValue({[number_of_requests=1, search_term="Transalb"]})]))
in
Source

如果您想自己查看,令牌有效。

我不明白的是,我在使用这个在线 API 测试工具时得到了正确的响应:

POST /api/abfrage/ HTTP/1.1
Host: 3.93.175.1
Authorization: Token d04b033d7fa9760147aa32743284ace16de2bbd0
Content-Type: application/json
Content-Length: 52
{"number_of_requests":"1",
"search_term":"Transalb"}

很有魅力:

Server: nginx/1.21.6
Date: Sat, 28 May 2022 03:55:51 GMT
Content-Type: application/json
Content-Length: 48708
Connection: keep-alive
Vary: Accept
Allow: GET, POST, HEAD, OPTIONS
X-Frame-Options: DENY
X-Content-Type-Options: nosniff
Referrer-Policy: same-origin

{"Jahresabschluss zum Gesch\u00e4ftsjahr vom 01.01.2020 bis zum 31.12.2020": {"date": "2022-03-09T00:00:00", "name": "Jahresabschluss zum Gesch\u00e4ftsjahr vom 01.01.2020 bis zum 31.12.2020", "company": "Transalb K\u00fchl- und Express-GmbH", "report": "<!DOCTYPE html>\n<html lang=\"de\" data-signedin=\"nein\" data-siteid=\"3\">\n<head><script type=\"text/javascript\"}}

希望你能帮助我。 如果您需要更多信息,请大声喊叫。

我终于自己弄明白了,感谢这个伟大的 post:

https://community.powerbi.com/t5/Power-Query/Json-FromValue/td-p/1248394

只需要将我的请求更改为以下内容:

let

    Source = Json.Document(Web.Contents("http://3.93.175.1/api/abfrage/", [Headers=[Authorization="Token 6bcc8706f68d3635f1514ce22611e83c12b1e4c1", #"Content-Type"="application/json"], Content=Json.FromValue([number_of_requests="1", search_term="Transalb"])]))
in
    Source