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"",},}"- ericOnline8 years ago
Post Patron
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 responseI 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- ImkeF8 years ago
Community Champion
Just to make sure to understand your request:
1) For me a recursive action means that it picks up something from a previous action in order to continue.
I cannot spot that in your example. So could it be that you mean "iteratively" instead?: Go through a table with parameters and pass one row of it into each API-call?
2) With some additional escape signs and indizes, your "content" can be parsed out as a nested Record like so:
Will this structure always be the same for every key-value-pair combination that has to be passed trough (there are 9 different "Key"-fields in there currently)?
- ericOnline8 years ago
Post Patron
Hello ImkeF, thank you for the reply.
1. You are correct. I mistakenly used "recursive" rather than "iterative".
2. Yes. Would like to use a table similar to below. Each record is a separate API call. I added numbers to the key:values above to show where in the query each cell would go.
This is a little different than how you laid out the table (records vs. columns).
3. Yes, the structure will always be the same for each call.