Forum Discussion

SJMC_LAB's avatar
SJMC_LAB
Regular Visitor
4 years ago

Json POST Request through each row

Hi, 

New query user here. I have a table with one column as "start date", and the second column as "end date". I need to make JSON POST query using the two dates as parameters to be passed through in a JSON body. How do I make POST query for each row and combine all data in a single table?

 

I know how to make a single working query, but how do I loop through each row in advanced editor? I have done some research, but i couldn't find similar situations using more than one columns as parameters. My working query is like this:

 

let

          url = " http://www.xxx.xxx/..... ",

          headers=[#"accept"="application/json", #"Content-Type"="application/x-www-form-urlencoded"],

          PostBody = [

                    user_id =  "lasf3sd5423e1dsd2asdsdsdf",

                    startTime = DateTime.ToText("2022-03-01", "yyyy-MM-dd h:mm"),

                    endTime = DateTime.ToText(DateTime.LocalNow(), "yyyy-MM-dd h:mm")

                      ], 

 

          response = Json.Document(Web.Contents(url,

                     [

                               Headers = headers,

                               Content = Text.ToBinary(Uri.BuildQueryString(PostBody))

                     ]

                    )),

 

In

response

 

Thank you!

1 Reply