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
I am trying to invoke a post-call in PowerBi using a custom query but I'm facing an error The post-call gets converted to a get call and it throws an error. I tried using basic auth directly and also by passing it in headers any advice or help is appreciated and thank you in advance.
let StartDate =Date.ToText(TimeStart,"yyyy-MM-ddTHH:ss:SSZ"), EndDate =Date.ToText(TimeEnd,"yyyy-MM-ddTHH:ss:SSZ"), auth_key ="Basic ZHNwX3JldGluZ191c2VyOk9DSXJlcG9ydHNAMjAyMA==", body = "{""tenantId"": "&tenancyName&",""granularity"": "&Duration&",""timeUsageStarted"": "&StartDate&",""timeUsageEnded"": "&EndDate&",""queryType"":"&CostType&",""groupBy"": ""[service]""}", Data= Web.Contents("http://localhost:8080/costanalysis?profile=str109348123®ion=london", [Headers=[#"Content-Type"="application/json", Authorization=auth_key]]), Content = Text.ToBinary(body), DataRecord = Json.Document(Data), Source=DataRecord in Source
This is the error in Bi
DataSource.Error: Web.Contents failed to get contents from 'http://localhost:8080/costanalysis?profile=str109348123®ion=london' (405😞 Details: DataSourceKind=Web DataSourcePath=http://localhost:8080/costanalysis Url=http://localhost:8080/costanalysis?profile=str109348123®ion=london
This is the stack error in JAVA end
c.d.o.exception.GlobalExceptionHandler : Something went wrong.Error Message : Request method 'GET' not supported 2020-12-29 11:27:53.260 WARN 20696 --- [nio-8080-exec-1] .m.m.a.ExceptionHandlerExceptionResolver : Failure in @ExceptionHandler com.dsp.oracle.exception.GlobalExceptionHandler#defaultErrorHandler(HttpServletRequest, Exception)
Solved! Go to Solution.
Hi @Anonymous
You have the Content outside the Web.Contents call. It should be like this
let
StartDate = Date.ToText(TimeStart,"yyyy-MM-ddTHH:ss:SSZ"),
EndDate = Date.ToText(TimeEnd,"yyyy-MM-ddTHH:ss:SSZ"),
auth_key ="Basic ZHNwX3JldGluZ191c2VyOk9DSXJlcG9ydHNAMjAyMA==",
body = "{""tenantId"": "&tenancyName&",""granularity"": "&Duration&",""timeUsageStarted"": "&StartDate&",""timeUsageEnded"": "&EndDate&",""queryType"":"&CostType&",""groupBy"": ""[service]""}",
Data = Web.Contents(
"http://localhost:8080/costanalysis?profile=str109348123®ion=london",
[
Headers = [#"Content-Type"="application/json", Authorization=auth_key],
Content = Text.ToBinary(body)
]
),
DataRecord = Json.Document(Data),
Source = DataRecord
in
Source
Because the Content was in the wrong place, Web.Contents was making GET requests rather than POST.
Regards
Phil
Proud to be a Super User!
Thank you it worked
Hi @Anonymous
You have the Content outside the Web.Contents call. It should be like this
let
StartDate = Date.ToText(TimeStart,"yyyy-MM-ddTHH:ss:SSZ"),
EndDate = Date.ToText(TimeEnd,"yyyy-MM-ddTHH:ss:SSZ"),
auth_key ="Basic ZHNwX3JldGluZ191c2VyOk9DSXJlcG9ydHNAMjAyMA==",
body = "{""tenantId"": "&tenancyName&",""granularity"": "&Duration&",""timeUsageStarted"": "&StartDate&",""timeUsageEnded"": "&EndDate&",""queryType"":"&CostType&",""groupBy"": ""[service]""}",
Data = Web.Contents(
"http://localhost:8080/costanalysis?profile=str109348123®ion=london",
[
Headers = [#"Content-Type"="application/json", Authorization=auth_key],
Content = Text.ToBinary(body)
]
),
DataRecord = Json.Document(Data),
Source = DataRecord
in
Source
Because the Content was in the wrong place, Web.Contents was making GET requests rather than POST.
Regards
Phil
Proud to be a Super User!
When I publish this it throws an error saying anonymous call error but other calls work fine as they have data source by default as basic auth
@Anonymous , For post method refer these two, if they can help, if not explored previously
I tried those but it didn't work. PowerBi still throws an error for basic auth or anonymous call either way the post gets converted to get by powerBi and authorization fails
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.