Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredGet Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now
Hi @amitchandak ,
Thanks for the link.
But I couldnt find a good solution among them.
Could you pls help to convert below query to M code?
Not enough details on the authentication method you want to use. Missing the password identifier, for example.
Querying Web.Contents with basic authentication | MrExcel Message Board
use the header [Headers =[#"Authorization"="Basic username:password"]]
And the username and password string must be encoded using base64 encoding
Hi @lbendlin ,
Thank you.
Finally I succeeded with the following code:
headers=[#"Content-Type"="application/json",Cookie=dict_cookie],
query=[],
content="",
web=Text.FromBinary(Web.Contents(rootURL,[Headers=headers,Query=query,Content=Text.ToBinary(content)]))But when I upload it to power bi report server,when I configure the data source as Anonymous, it returns an error as below:(In desktop I also configure as anonymous)
Web.Contents failed to get contents from 'http://10.108.115.192:9000/getStatusData' (405): METHOD NOT ALLOWEDWhy?Can you help me ?
Hi @lbendlin
I have adjusted my code as below:
let
rootURL="http://10.108.115.192:9000/getStatusData",
Credentials = "USERNAME=""xxxx"":PASSWORD=""xxxx""",
EncodedCredentials = "Basic " & Binary.ToText(Text.ToBinary(Credentials), BinaryEncoding.Base64),
dict_cookie="{permission=""u"";uid=20;uname=""xxxx""}",
headers=[#"Content-Type"="application/json",#"Authorization"="EncodedCredentials",Cookie=dict_cookie],
query=[],
content=""
web=Text.FromBinary(Web.Contents(rootURL,[Headers=headers,Query=query,Content=Text.ToBinary(content)]))
in
webAlso I succeeded in desktop,but failed in report server, is there any error?
I have checked the server setting,seems a get request, is there any workround to fix such senario?
Hi @hellokelly ,
Pay more attention to status code 304.
Do you have a on-premises gateway installed? If the desktop refresh is successful, please try to refresh the cloud data using the on-premises gateway.
https://docs.microsoft.com/en-us/power-bi/connect-data/service-gateway-mashup-on-premises-cloud
Best Regards
Community Support Team _ chenwu zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Re-read the part about how to encode credentials.
Hi @lbendlin ,
Have tried using credentials:
let
rootURL="xxxx",
dict_cookie="{permission=""u"";uid=20;uname=""xxxx""}",
Credentials = "USERNAME=""xxxx"":PASSWORD=""xxxx""",
EncodedCredentials = "Basic " & Binary.ToText(Text.ToBinary(Credentials), BinaryEncoding.Base64),
headers=[#"Content-Type"="application/json",#"Authorization"="EncodedCredentials",Cookie=dict_cookie],
query=[],
content="",
web=Text.FromBinary(Web.Contents(rootURL,[Headers=headers,Query=query,Content=Text.ToBinary(content)]))
in
web
But no use.The problem is when I tested in desktop,it is sending a post request with cookie,but in report server,whatever I wrote in power query,it always sent a get request without cookie inside.Do you know why?
your credentials string is still incorrect, needs to be in this format:
Credentials = "xxxx:xxxx",
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
Check out the October 2025 Power BI update to learn about new features.