The current Zapier steps i have set up creates a GET request to an external service. that service replies with a list of data that is nested. My end step i need to do is make multiple PUT requests to another API with part of the URL being a value from the response from the GET. There is not a fixed number of id’s/times that it will need to PUT.
Currently if i do it with just the GET then the next step is the PUT it puts all of the values of the ID i need to put at the end of the API url as just a comma separated list. I need them to make separate PUT requests for Each ID.
Any help would be greatly appreciated.
This shows the response to the GET request (Images shows only the first part. There will are more in the response)
This is the PUT request. It currently puts them as a comma separated list. which causes an error. each of the values needs to process as a separate PUT.
You may want to consider writing your own code step to format the nested data into an array of objects (JSON). You could then return the data to output and achieve the effect you're looking for, where the next Step runs a PUT request for each item in your output array.
Here are Zapier's notes on this strategy:
Setting the output to an array of objects will run the subsequent steps multiple times — once for each object in the array. If Code by Zapier is the Zap's trigger and an empty array is returned, nothing happens. You can think of it like a polling trigger that did not get any results in the HTTP response. This functionality is exclusive to triggers — returning an empty array in a Code by Zapier action does not have the same effect.
Related
I'm trying to create an Azure Logic API that calls API1, gets a list of IDs then passes those IDs into another API call to API2 to see if the ID already exists. If it does not I want it to create the ID in API2.
I've set it up as a timer-base trigger. When triggered I have it making an API request to get a list of IDs from the first API. It then parses the JSON so that I can use the IDs in a Foreach loop to take the IDs from one API and compare them with IDs from another API. It's then parsing the JSON response for another foreach loop to evaluate if it exists then skip and if it doesn't create the new IDs.
The problem I'm having is when it doesn't exist in the second API it never kicks off the API request to create the IDs in the second API. The most logical way to set it up is if API1-ID does not equal API2-ID, then true otherwise false. The problem is, if the ID doesn't exist in API2 there's nothing to evaluate for true/false so the API call to create never execute. I had assumed that if ID didn't exists then it wasn't equal, so it would be true.
I've even tried to use the empty expression or length if the JSON response body is zero, but I cannot get this fire off the API request to create the missing IDs. I feel like this can work because I've flipped it to where if ID = ID then it creates the ID (which gives me duplicates).
If anyone can help that would be awesome!
ajaxLoader:true,
ajaxFiltering:true,
ajaxProgressiveLoad:"scroll",
ajaxProgressiveLoadDelay:200,
ajaxConfig:"POST",
ajaxProgressiveLoadScrollMargin : 10,
I used the above settings and worked in the order below.
clearFilter();
addFilter()
setData()
At this time, 3 requests occur.
One request with no filter applied.
The filter applied has been requested twice.
What's the problem?
That is correct operation of the table. You have Ajax filtering enabled in your settings.
When you clear the filters a request must be made to retrieve the unfiltered data.
Then when you add a filter it must request the filtered data.
Then when you change the data URL with set data it makes another request.
If all you want to do is set a filter then there is no need to call clearFilter then addFilter then setData, you can simply call setFilter which will do all of the above in one action with one request.
table.setFilter("age", "=”, 12);
You only need to call the setData function in this instance if you want to change the base url of the request.
An explanation of this can be found in the first section of the Filter Documentation
I have a view function that needs to gather multiple pieces of information in one call (it's a quick outbound call - the user answers and is to be immediately prompted for these data points), based on data pulled from a DB. What I'd like the view function to do is something like the following:
group_id = <get group id>
params = data_element_select_params.DataElementSelectParams(group_id=group_id)
data_elements = worker.select(params) # function I wrote which returns a list of objects, in this case objects called DataElements
vr = VoiceResponse()
say_msg = 'Enter {element}, then press star.'
for element in data_elements:
say_message = say_msg.format(element=element.name)
<Gather input with say_message and save it>
Can this be achieved without routing to the same URL over and over? I have not seen any other solution, and I'd rather not continually redirect to the same URL as we'll have to pull the list of elements from the DB again for each element.
Apologies if anything is unclear - please point it out and I'll clarify as quickly as I can.
Twilio developer evangelist here.
You can only use one <Gather> per TwiML document, so no, you can't ask multiple questions and take multiple inputs within the one webhook.
You will need to route to a URL that receives the input from each <Gather> and then asks the next question.
To avoid pulling all the elements from the DB every time, you could investigate saving the elements to the HTTP session and pulling them back out of there. Twilio is a well behaved HTTP client, so you can use things like cookies to store information about the current call/conversation.
I have the following layout. If the Export to Excel checkbox is not checked, upon the button being pressed an API call will be made to query the data in the date range, and displayed in d3 graphs below. If it is checked, the button makes the same API call, in addition to referencing a 2nd call that downloads an Excel file. I think these 2 separate calls are necessary because I need the data in both forms (json and an attachment) which both require separate headers. I wasn't able to figure out a way to make just one call and return the data both ways, but if that's possible I would be open to that solution. Otherwise, what are my options to query the data just once, and share it between both calls?
A HTTP request can only respond with one response type. So with a single request you can only return json or excel (whatever encoding you used). When you click that button and the excel checkbox is checked, do you need both responses? Or just the file?
If you just want the file, then ignore the JSON and do not update your d3 graphs.
If you want the graphs and the file, you'll have to make two requests, one for the JSON and one for the file. If you want to only process that DB call once on the server, you'd need something else. Like, return the JSON data and store the file at a link you'll know the address to. Or return the file and push the JSON to the client (WebSocket or similar).
If you can cache on the server (caching DB like redis or in-memory if you can guarantee you'll hit the same server node), you could store/hash the query parameters with the returned data. Any future call would check that cache first and maybe not hit the DB. (Of course, be aware that if any data would update the results, you'll need to kill your cache key so the data is requeried).
Some web design questions.
Combine POST with GET?
When user clicks a button, I need to send one POST to submit a form, then need to GET a json object to replace some DOM fields. Should I combine them into one request so save one round trip time?
Multiple GET json request?
When user clicks a button, I need to GET 3 or 4 json object. Should I send 3 or 4 GET request, or just one and combine the json into one large json at back-end?
So basically, I'm not sure which is heavier: round trip time VS a little complexed back-end and front-end logic.
Any comment is welcome!
if i understood your question right...you have a dependency on your get requests...that is to say the second get depends on the first...if that is the case, obviously you need to take consecutive get operations...however, if that is not the case that is if you know the order of get request and the response won't be affected by local conditions...then i suggest you do post/get operations on server side...trigger the first one an let the server handle the rest and get the result...
of course you would not want users do multiple get requests for one simple operation...