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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
SylvainN
Frequent Visitor

Try to convert curl into powerquery

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

1 ACCEPTED SOLUTION
SylvainN
Frequent Visitor

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

View solution in original post

6 REPLIES 6
SylvainN
Frequent Visitor

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"

SylvainN
Frequent Visitor

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]),

SylvainN
Frequent Visitor

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([""]),


lbendlin
Super User
Super User

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.

 

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

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.