Forum Discussion
Passing Variables in API Post Request JSON Body
- 8 years ago
Hi saikishore,
you don't use the parameter "locid" as text in your function at all. If your expression in step "body" is supposed to do this: It will not work. If locid is a single text string, you have to concatenate it like so:
"{""locationNames"":"& locid &",#(lf)""drivingDirectionsRequest"": {""numDays"":""NINETY"",},}"
Hi saikishore,
you don't use the parameter "locid" as text in your function at all. If your expression in step "body" is supposed to do this: It will not work. If locid is a single text string, you have to concatenate it like so:
"{""locationNames"":"& locid &",#(lf)""drivingDirectionsRequest"": {""numDays"":""NINETY"",},}"Hello ImkeF, v-yuta-msft,
The title of this post extactly matches my question.
How can I pass key : value pairs from a table rather than 1 by 1?
Here is my example API call (works great):
let
url = "https://company.com/api/path",
headers = [
"apikey" = thisisnotreallymyapikey
"accept" = application/json,
"Content-Type" = application/json
],
content = "{
""key"": {
""nestedKey"": value1,
""nestedKey"": value2
},
""key"": """",
""key"": ""value3"",
""key"": ""value4"",
""key"": value5,
""key"": [
{""key1"": ""value6"", ""key2"": ""value7""}
]
}",
webdata = Web.Contents(url, [Headers=headers,Content = Text.ToBinary(content)]),
response = Json.Document(webdata)
in
response
I need to have a table of key:value pairs that my query can hit iteratively until complete.
Example:
- Query refers to a table
- Pulls all key:value pairs accordingly
- Sends POST call to API
- Saves data to a table
- Repeats
- Appends data to a table until all calls have been made.
I don't know how to go about this. Any advice you can give is much appreciated.
Thank you