POWER QUERY - json 请求中的有效负载格式无效

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

我正在 Power BI 的 Power Query 中开发请求,遇到以下错误:

json 请求中的负载格式无效。

按照代码操作:

let

URL1 = "example/login",
POST = [
    #"Content-Type" = "application/json",
    Token = "TOKEN HERE",
    Appkey = "APPKEY HERE",
    Username = "USER HERE",
    Password = "PASS HERE"
    ],

postData = Text.ToBinary(""),
Resposta = Web.Contents(
    URL1,
    [
        Headers = POST,
        Content = postData
    ]
),
Fonte1 = Json.Document(Resposta),
BearerToken = Fonte1[bearerToken],

Body = "{""serviceName"": ""example.loadRecords"",
        ""requestBody"": {
            ""dataSet"": {
                ""rootEntity"": ""example"",
                ""includePresentationFields"": ""S"",
                ""offsetPage"": ""0"",
                ""criteria"": {
                    ""expression"": {
                        ""$"": ""(this.example= ? )""
                    },
                    ""parameter"": {
                        ""$"": ""01/08/2023"",
                        ""type"": ""D""
                    }
                },
                ""entity"": {
                    ""fieldset"": {
                        ""list"": ""example,example,example,example,example,example,example""
                    }
                }
            }
        }"
        ,

URL2 = "example/gateway/v1/example/example.sbr?example=example.example&outputType=json",
GET = Web.Contents(
    URL2,
        [
            Headers = [
                #"Content-Type"="application/json",
                Authorization="Bearer "&BearerToken
                ],
            Content = Text.ToBinary(Body)
        ]),

Fonte2 = Json.Document(GET),
Table1 = Record.ToTable(Fonte2)
in 
Table1 

这种情况有人可以帮助我吗?

我尝试更改正文的输入格式以及 GET 的标头。

json api post get powerquery
1个回答
0
投票

主体未输出有效的 JSON

{"serviceName": "example.loadRecords",
    "requestBody": {
        "dataSet": {
            "rootEntity": "example",
            "includePresentationFields": "S",
            "offsetPage": "0",
            "criteria": {
                "expression": {
                    "$": "(this.example= ? )"
                },
                "parameter": {
                    "$": "01/08/2023",
                    "type": "D"
                }
            },
            "entity": {
                "fieldset": {
                    "list": "example,example,example,example,example,example,example"
                }
            }
        }
    }

我通过另存为文本文件并尝试带回 Powerquery 以及使用 JSON 验证器进行了测试https://jsonlint.com/

也许如果你做对了,它就会起作用

© www.soinside.com 2019 - 2024. All rights reserved.