admin管理员组文章数量:1122832
When using the following code:
let
url = ";,
headers = [#"Content-Type"="application/json"],
body = "{
""query"": [{""code"":""Region"",
""selection"":{""filter"":""item"",""values"":[""00""]}},
{""code"":""Hustyp"",
""selection"":{""filter"":""item"",""values"":[""1113"",""21""]}}],
""response"": {""format"":""csv""}
}",
Source = Json.Document(Web.Contents(url,[Headers = headers,Content = Text.ToBinary(body)]))
in
Source
I receive the following error:
DataFormat.Error: We found extra characters at the end of the JSON input.
Details:
Value=,
Position=8
As I am new to this, I am not sure what's wrong. It works in Postman, but cannot get it to work in PowerQuery.
I tried to mimic what's done here:
Thanks!
When using the following code:
let
url = "https://api.scb.se/OV0104/v1/doris/en/ssd/BO/BO0101/BO0101G/LghHustypKv",
headers = [#"Content-Type"="application/json"],
body = "{
""query"": [{""code"":""Region"",
""selection"":{""filter"":""item"",""values"":[""00""]}},
{""code"":""Hustyp"",
""selection"":{""filter"":""item"",""values"":[""1113"",""21""]}}],
""response"": {""format"":""csv""}
}",
Source = Json.Document(Web.Contents(url,[Headers = headers,Content = Text.ToBinary(body)]))
in
Source
I receive the following error:
DataFormat.Error: We found extra characters at the end of the JSON input.
Details:
Value=,
Position=8
As I am new to this, I am not sure what's wrong. It works in Postman, but cannot get it to work in PowerQuery.
I tried to mimic what's done here: https://community.fabric.microsoft.com/t5/Power-Query/Sending-a-POST-API-request-using-PowerQuery-on-Excel-PBI-with-a/td-p/2764875
Thanks!
Share Improve this question edited Nov 22, 2024 at 19:51 Brian Tompsett - 汤莱恩 5,87572 gold badges61 silver badges133 bronze badges asked Nov 22, 2024 at 19:34 getFEAgetFEA 11 bronze badge1 Answer
Reset to default 0It's easier to let Power Query build the raw json string for you.
The other tip is save your response before converting to JSON.
I added the AsText
field. It'll let you view the raw response from the server.
let
baseUrl = "https://api.scb.se",
headers = [#"Content-Type" = "application/json"],
body = [
query = {
[
code = "Region",
selection = [
filter = "item",
values = {"00"}
]
],
[
code = "Hustyp",
selection = [
filter = "item",
values = {"1113", "21"}
]
]
},
response = [
format = "csv"
]
],
bytes = Web.Contents( baseUrl, [
RelativePath = "/OV0104/v1/doris/en/ssd/BO/BO0101/BO0101G/LghHustypKv",
Headers = headers,
Content = Json.FromValue(body)
]),
Json = Json.Document( bytes ),
AsText = Text.FromBinary( bytes )
in
[
Json = Json,
AsText = AsText
]
( If you can link the documentation for your Web API, it's easier to answer. )
本文标签: javascriptPOST API request using PowerQuery in ExcelStack Overflow
版权声明:本文标题:javascript - POST API request using PowerQuery in Excel - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736301209a1931100.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论