Power BI Web.contents with bearer token (as generated variable) can't authenticate

问题描述 投票:0回答:0

谢谢帮忙。 我正在尝试检索需要不记名令牌进行授权的 api 数据,但我不断收到“我们无法使用提供的凭据进行身份验证”

我有生成令牌的功能

`= ()=>
let 
 url = "https://xxxxx.xxxx.xxxxx/test/api/v2/xxxxxx/login",
 
    content = "{
        ""username"": ""xxxxxxx"",
           ""password"": ""xxxxxx*""
    }",

 GetJson = Web.Contents(url,
     [
         Headers = [
                    #"Content-Type"="application/json"],
         Content = Text.ToBinary(content) 
     ]
 ),
 FormatAsJson = Json.Document(GetJson),
 // Gets token from the Json response
 AccessToken = FormatAsJson[result][accessToken],
 AccessTokenHeader = "bearer " & AccessToken
 in AccessTokenHeader`

这成功生成了一个令牌。我创建了一个查询来引用列表列,以改变我的 api 调用中的跳过参数。

我的主要查询如下:

`let
    token = gettoken(),
    Custom1 = List.Numbers(0,1000000,500),
    #"Converted to Table1" = Table.FromList(Custom1, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
    #"Changed Type1" = Table.TransformColumnTypes(#"Converted to Table1",{{"Column1", type text}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type1", "Custom", each Json.Document(Web.Contents("https://xxxx.xxxxx.xxx.xx.xx/test/api/v2/xx/xx?$filter=documentYear gt 2019&$top=500&$skip="&[Column1]&", [Headers=[Authorization="&token&"]]")))
in
    #"Added Custom"`

如前所述,我不断收到“我们无法使用您提供的凭据进行身份验证...”错误,在“访问网络内容”屏幕上选择匿名也无济于事。

任何提示将不胜感激。

谢谢,

伍迪

api powerbi http-headers bearer-token powerbi-datasource
© www.soinside.com 2019 - 2024. All rights reserved.