You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Power Query调用REST API填充列时Authorization头权限报错求助

解决Power Query中调用带Bearer令牌的REST API权限错误问题

问题背景

在Power Query中处理一列ID列表,需为每行单独调用REST API获取对应信息(无批量查询API)。该API需使用动态访问令牌,已通过自定义GetToken()函数获取令牌。

尝试添加如下自定义列代码:

Json.Document(
Web.Contents(
    Text.Combine({"https://urlthatholdstheinfo.com/", [id]}), [Headers=[Authorization="Bearer "& GetToken()]]))

遇到的错误

Expression.Error: The 'Authorization' header is only supported when connecting anonymously. These headers can be used with all authentication types: Accept, Accept-Charset, Accept-Encoding, Accept-Language, Cache-Control, Content-Type, If-Modified-Since, Prefer, Range, Referer

此前曾通过设置数据源匿名权限解决同类问题,但找不到当前查询的设置入口;尝试在Web.Content中传入匿名参数也未成功。

解决方案

通过以下步骤可解决报错:

  • 创建一个带固定ID的空白查询,使用如下代码:
let
Source = 
Json.Document(
    Web.Contents(
            "https://urlthatholdstheinfo.com/id", 
                [Headers=[Authorization="Bearer "& GetToken()]])),
in
   Source
  • 找到该空白查询的数据源设置,将权限改为匿名
  • 注意:移除原代码中的大括号[](即原代码中包裹[id]的部分需调整为正确的文本拼接方式)

完成以上设置后,原自定义列和函数的报错即可消除。

内容的提问来源于stack exchange,提问作者AlbaTroels

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.31 14:40:44