Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
Hi,
I'm trying to get a POST method to work with WebAPI but it's throwing below the errosr that I tried with 2 parameters. It's working completely fine on Postman.
Method 1 using X-ApiKey Authentication without Content=Text.FromBinary("") :
let
Http_query = Web.Contents("https://api.website.com/api/GetAllProfiles",
[Headers=[#"X-ApiKey"="<ApiKey>",
#"Content-Type"="application/json"]])
in
Http_query
ERROR:
DataSource.Error: Web.Contents failed to get contents from 'https://api.website.com/api/GetAllProfiles' (405): Method Not Allowed
Method 2 using X-ApiKey Authentication with Content=Text.FromBinary("") :
let
Http_query = Web.Contents("https://api.website.com/api/GetAllProfiles",
[Headers=[#"X-ApiKey"="<ApiKey>",
Content=Text.FromBinary(""), #"Content-Type"="application/json"]])
in
Http_query
ERROR:
Expression.Error: We cannot convert the value "" to type Binary.
Details:
Value=
Type=[Type]
Postman Authorization screenshot adding for reference where it's showing the results as required.
Any help would be appreciated to rectify this issue. Thanks
The first one won't work as Web.Contents need you to specify Content to POST, without it the function defaults to GET:
https://docs.microsoft.com/en-us/powerquery-m/web-contents
The second one doesn't work because you're not specifying where the binary is coming from.
@otravers i also tried another method to authenticate via Body which is also working fine on Postman but throws error in Power Bi as commented below. Any help on that will be helpful.
The Body would typically be some payload (e.g. a JSON array) that your API is expecting in the POST:
@otravers What should i add in (Body) since i am getting error if i use below query:
May you could rewrite this to better clairfy. Thanks
let
Http_query = Web.Contents("https://api.website/api/GetAllProfiles",
[Headers=[#"X-ApiKey"="<ApiKey>",
Content=Text.FromBinary(Body), #"Content-Type"="application/json"]])
in
Http_query
Error
Expression.Error: The name 'Body' wasn't recognized. Make sure it's spelled correctly.
Sorry that was poorly phrased. I'm running out so can't go into details, but you need to specify something in the Text.FromBinary() part.
@otravers
I also tried another method to authenticate via Body which is also working fine on Postman but throws error in Power Bi as shown below:
Body=
[
#"apiKey"= "<ApiKey>"
],
webdata = Web.Contents("https://api.website.com/api/Profile/GetAllProfiles",
[Headers=[#"Content-Type"="application/json"],
Content=Text.FromBinary(Body)
])
in
webdata
Error:
Expression.Error: We cannot convert a value of type Record to type Binary.
Details:
Value=
apiKey=<ApiKey>
Type=[Type]
Screenshot from Postman
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!