【问题标题】:Expression Error When Returning Value to Record返回值以记录时出现表达式错误
【发布时间】:2021-07-17 02:06:00
【问题描述】:

我正在尝试发出此 POST 请求以检索要作为记录存储在表中的 JWT 令牌。它确实检索令牌。但是,我收到错误“Expression.Error:我们无法将值“eyJhbGciOiJIUzI1NiIs...”转换为类型 Record.Type=[Type]”。想想我哪里出错了?

let
    url = "https://sapif.callminer.net/security/getToken", 
    body = "{""Username"": ""xxxxx"", ""Password"": ""xxxx"", ""ApiKey"": ""xxxxxx""}",
    Parsed_JSON = Json.Document(body),
    BuildQueryString = Uri.BuildQueryString(Parsed_JSON),
    token = Json.Document(Web.Contents(url,[Headers = [#"Content-Type"="application/json; charset=utf-8"], Content = Text.ToBinary(body) ] )),
#"Converted in table" = Record.ToTable(token)
in
#"Converted in table"

【问题讨论】:

    标签: json jwt powerbi token powerquery


    【解决方案1】:

    想通了: let url = "https://sapif.callminer.net/security/getToken", body = "{""Username"": ""svc-piautomation@alegeus.com"", ""Password"": ""3tmvF7c_U=ZCHywW"", ""ApiKey"": ""alegeus""}", Parsed_JSON = Json.Document(body), BuildQueryString = Uri.BuildQueryString(Parsed_JSON), token = Json.Document(Web.Contents(url,[Headers = [#"Content-Type"="application/json; charset=utf-8"], Content = Text.ToBinary(body) ] )), #"Converted in table" = Record.ToTable([Token = token]) in #"Converted in table"

    【讨论】:

    • 我不明白这个答案,希望您能提供帮助。 body 是提前定义的,然后将其转换为 JSON 并构建为 BuildQueryString 的查询字符串。但是BuildQueryString 没有在您的Web.Contents 请求中使用——body 是。但是body 没有被修改。您在请求中是否使用了bodyBuildQueryString
    猜你喜欢
    • 1970-01-01
    • 2019-09-17
    • 1970-01-01
    • 2014-11-27
    • 1970-01-01
    • 1970-01-01
    • 2020-11-18
    • 1970-01-01
    • 2014-07-22
    相关资源
    最近更新 更多