PowerBI Service中调用XSOAR API /incidents/search端点的带API Key POST请求刷新失败问题求助
大家好,我最近在做PowerBI对接XSOAR API的需求,调用/incidents/search端点通过POST请求拉取数据,手里有合法的API Key,现在遇到了一个棘手的问题,想请教各位大佬:
桌面版运行正常的情况
我在PowerBI Desktop里写的M查询完全能正常工作,代码如下:
let url = "https:/XSOARSERVER/acc_ACCOUNT/incidents/search", headers = [#"Accept"="application/json", #"Content-Type"="application/json", #"Authorization"="XXXXXXXXXXXXXXX"], body = {filter={query=""}}, content = Json.FromValue(body), Source = Json.Document(Web.Contents(url, [Headers= headers, Content= content])) in Source
这段代码能成功请求到XSOAR的数据,没有任何问题。
PowerBI Service刷新失败的问题
但是当我把这个报表上传到PowerBI Service后,刷新就完全失效了。加载一段时间后会弹出错误:
Data source error[ValidateMarkupTags][ccon]DataSource.Error: [ccon]Unable to connect to the remote server[/ccon].
[ccon]https://XSOARSERVER/acc_ACCOUNT/incidents/search[/ccon]. [/ccon];[ccon]Unable to connect to the remote server[/ccon].
The exception was raised by the IDbCommand interface. Table: Query1.
尝试过的替代方案及问题
我尝试修改了查询,把API Key放到PowerBI的凭据里管理,用ApiKeyName参数来传递,修改后的代码如下:
let url = "https:/XSOARSERVER/acc_ACCOUNT/incidents/search", headers = [#"Accept"="application/json", #"Content-Type"="application/json"], body = {filter={query=""}}, content = Json.FromValue(body), Source = Json.Document(Web.Contents(url, [Headers= headers, Content= content, ApiKeyName = "Authorization"])), in Source
但这种方式直接报错,提示:
Web.Contents with the Content option is only supported when connecting anonymously.
现在我想请教各位,有没有什么办法能让这个POST请求在PowerBI Service里正常刷新?或者是不是PowerBI Service确实不支持带API Key的POST请求作为数据源?
感谢各位的帮助!
备注:内容来源于stack exchange,提问作者pocpoc47

