Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
the Curl where it work
curl --location --request POST "https://MyWebSite:3129/v1/blocklist" ^
--header "X-APIKey: MyKey" ^
--Content-Type"="application/json
the answer is {"error":"Success","response":{"blocklists":[{"blocklistid":"11111111111","name":"Serveur 2008"}]}}
And the powerquery
let
url = "https://MyWebSite:3129/v1/blocklist",
headers = [#"X-APIKey" ="MyKey",
#"Content-Type"="application/json"],
response = Web.Contents(
url,
[ Headers = headers ]
),
jsonResponse = Json.Document(response)
in
jsonResponse
Error from powerquery
DataSource.Error: Web.Contents failed to get contents from 'https://MyWebSite:3129/v1/blocklist' (405): Method Not Allowed
Details:
DataSourceKind=Web
DataSourcePath=https://MyWebSite:3129/v1/blocklist
Url=https://MyWebSite:3129/v1/blocklist
Don't understand why it not working, thx for the help
Solved! Go to Solution.
Ok it good to know I need to specify a payload, but don't know how to apply, I read the website but do not find the info how to apply payload
I try to appy this
let
url = ...,
headers = [#"Content-Type" = "application/json"],
postData = Json.FromValue([x = 235.7, y = 41.53]),
response = Web.Contents(
url,
[
Headers = headers,
Content = postData
]
),
jsonResponse = Json.Document(response)
in
jsonResponse
let
url = "https://my website:3129/v1/blocklist",
headers = [#"X-APIKey" ="my key",
#"Content-Type"="application/json"],
postData = Json.FromValue([""]),
response = Web.Contents(
url,
[ Headers = headers
Content = postData
]
),
jsonResponse = Json.Document(response)
in
jsonResponse
Find the payload
let
url = "https://mywebsite:3129/v1/blocklist",
headers = [#"X-APIKey" ="my key",
#"Content-Type"="application/json"],
body = "{""}",
response = Web.Contents(
url,
[ Headers = headers,
Content = Text.ToBinary((body))
]
),
jsonResponse = Json.Document(response),
response1 = jsonResponse[response],
blocklists = response1[blocklists],
blocklists1 = blocklists{0},
#"Converted to Table" = Record.ToTable(blocklists1)
in
#"Converted to Table"
Ok it good to know I need to specify a payload, but don't know how to apply, I read the website but do not find the info how to apply payload
I try to appy this
let
url = ...,
headers = [#"Content-Type" = "application/json"],
postData = Json.FromValue([x = 235.7, y = 41.53]),
response = Web.Contents(
url,
[
Headers = headers,
Content = postData
]
),
jsonResponse = Json.Document(response)
in
jsonResponse
let
url = "https://my website:3129/v1/blocklist",
headers = [#"X-APIKey" ="my key",
#"Content-Type"="application/json"],
postData = Json.FromValue([""]),
response = Web.Contents(
url,
[ Headers = headers
Content = postData
]
),
jsonResponse = Json.Document(response)
in
jsonResponse
Did it work?
Try
postData = Json.FromValue([x=0]),
I'm quite new to powerbi but how do I specify a payload, could you give me an example?
Or maybe this can work
postData = Json.FromValue([""]),
Please follow the documentation. https://learn.microsoft.com/en-us/powerquery-m/web-contents#example-2
You need to specify a payload to make Web.Contents do a POST.
Your API is misbehaving as it accepts POST requests without payloads.
To solve that provide an empty string as the payload.
User | Count |
---|---|
70 | |
70 | |
34 | |
23 | |
22 |
User | Count |
---|---|
96 | |
94 | |
50 | |
42 | |
40 |