使用 Power 查询访问 Post Rest Api
Posted
技术标签:
【中文标题】使用 Power 查询访问 Post Rest Api【英文标题】:Acessing Post Rest Api using Power query 【发布时间】:2021-12-09 03:43:48 【问题描述】:我是 Power BI 和电源查询的新手,我正在尝试从 Post rest api 获取 JSon 数据。但我总是收到 400 错误。我哪里错了。
let
authkey ="Bearer xxxx",
url = "https://example.com/xxx",
body = """objectId"":""settlement_entity"",""queryString"":""?itemrefs=settlementreference,itemdescription&perpage=12&includekeyitems=true&includeforeignkeyitems=true&includetimestamp=true&includeadditionalmeta=true""",
Source = Json.Document(Web.Contents(url,
[
Headers = [#"Authorization"= authkey,#"Content-Type"="application/json"], Content = Text.ToBinary(body)
]
))
in
Source
【问题讨论】:
【参考方案1】:好的,我解决了正文缺少方括号的问题
let
authkey ="Bearer xxxx",
url = "https://example.com/xxx",
body = "[""objectId"":""settlement_entity"",""queryString"":""?itemrefs=settlementreference,itemdescription&perpage=12&includekeyitems=true&includeforeignkeyitems=true&includetimestamp=true&includeadditionalmeta=true""]",
Source = Json.Document(Web.Contents(url,
[
Headers = [#"Authorization"= authkey,#"Content-Type"="application/json"], Content = Text.ToBinary(body)
]
))
in
Source
【讨论】:
以上是关于使用 Power 查询访问 Post Rest Api的主要内容,如果未能解决你的问题,请参考以下文章
使用 Power Query 通过 REST API 查询分页 XML
使用 REST API 查询 Sharepoint Online 并在正文中传递查询 (POST)