Forum Discussion
CatParky
6 years agoFrequent Visitor
Help : Create POST api request using double quotes in body to format payload
Hi, I'm trying to write a query that will format and POST an excel table contents to a Knack database using their api. So far I have the following query using the custom GetJson function from Chr...
- 6 years ago
I think the issue is that you are double formatting the data.
Remove:
body = GetJson(#"Promoted Headers"),change
Content = Text.ToBinary(body)to
Content = Json.From(#"Promoted Headers")And hopefully that should work.
Actually, looking into this further. You need to use a single row in a table, not the entire table... E.g.
change
Content = Json.From(#"Promoted Headers")to
Content = Json.From(#"Promoted Headers"{0})if you just want to use the first row of the table.
artemus
6 years agoMicrosoft Employee
I think the issue is that you are double formatting the data.
Remove:
body = GetJson(#"Promoted Headers"),
change
Content = Text.ToBinary(body)
to
Content = Json.From(#"Promoted Headers")
And hopefully that should work.
Actually, looking into this further. You need to use a single row in a table, not the entire table... E.g.
change
Content = Json.From(#"Promoted Headers") to
Content = Json.From(#"Promoted Headers"{0})
if you just want to use the first row of the table.
CatParky
6 years agoFrequent Visitor
My error !
I skip read the part about removing
body = GetJson(#"Promoted Headers"),
I also updated to Jason.FromValue and it's worked @:
Source = Json.Document(Web.Contents(url,[
Headers = [#"X-Knack-Application-Id"=AppID,
#"X-Knack-REST-API-Key"=AuthKey,
#"Content-Type"="application/json"],
Content = Json.FromValue(#"Promoted Headers"{0})
]
))
in
Source