Webhook only works for 1st record added on Import of multiple records

  • 0
  • 1
  • Question
  • Updated 8 months ago
  • In Progress
I created a webhook that fires when a new record is added or modified in a table. When I add records one at a time, it works fine. But when I import multiple records to that table, it only works for the first record from the Excel, but not for the other records. (All the records do get imported correctly to Quickbase, so it doesn't seem to be an issue with the import function. Also, the webhook is not throwing any errors.)
Photo of Michael

Michael

  • 160 Points 100 badge 2x thumb

Posted 9 months ago

  • 0
  • 1
Photo of Evan Martinez

Evan Martinez, Community Manager

  • 9,264 Points 5k badge 2x thumb
Hi Michael,

Users run into this issue most often when using an API_AddRecord for their webhook, what happens is that the action fires once upon a bulk add and so only the first record is captured. Alternatively API_ImportFromCSV is a call that allows for multiple records to be captured upon add and moved over to another. It does require a slightly different syntax which can be found on our API Guide entry for API_ImportfromCSV. This call is more robust and it will allow for bulk adds to be captured. I hope this information is helpful Michael and thank you for your time today. 
Photo of Michael

Michael

  • 160 Points 100 badge 2x thumb
Thanks Evan, I'll try that.
Does it matter if the import is from CSV or Excel?
I'm using the webhook to take the information and send it to an external service - does that make a difference using API_ImportfromCSV?
Photo of Evan Martinez

Evan Martinez, Community Manager

  • 9,264 Points 5k badge 2x thumb
There may be some difference in the output depending on the other service you are exporting to. What it does is take the bulk data and transform it into a CSV format allowing it to capture more the one record. CSVs tends to be compatible with a number of services but depending on the API that you are using with the other service it might not be set up to take a CSV of data. What service are you attempting to connect to? It is possible someone on the forum may be familiar with if a CSV format upload would work for that service. 
Photo of Michael

Michael

  • 160 Points 100 badge 2x thumb
Hi Evan, To clarify, we're not doing a bulk movement of information. It just seems the webhook works for the first record, and not the other records when we import to QB. I think the webhook should fire for each new record added, but there's a rate limit on webhooks of 10 per second. I think this is why the webhook doesn't fire for the other records in the import. Do you know how to work around this rate limit when importing to QB, and the import creates a lot of records in a fraction of a second? (If that's even the problem.)
Photo of Evan Martinez

Evan Martinez, Community Manager

  • 9,264 Points 5k badge 2x thumb
Hi Michael,

Yes that is a known limitation in the API AddRecord with Webhooks, if you do an import into Quick Base it will only fire on the first add. Alternatively, when doing an import in ImportFromCSV is set to capture all of the records. This is because webhooks will fire only once and mark themselves as complete, so a single AddRecord fires off the first record and the others are left behind. ImportFromCSV on the other hand captures all added records in one go as a CSV whether it is 1 record of 100 records.
Photo of Michael

Michael

  • 160 Points 100 badge 2x thumb
Hi Evan,
In that case, is there a workaround that would allow us to still import using the normal import/export UI in Quickbase? It seems like you're suggesting that we build our own import portal from scratch and use the ImportFromCSV method.

What if the webhook was re-written to query the table's Date Created (Field ID#1) or Date Modified (Field ID#2), and get all the records that were just created in the last 1 minute (or some short time period). Then a separate script could loop through them and push them to the external API we're integrating with.

In other words, the webhook triggers a query on that table, then collects the recently created or modified records (it may be just one or maybe several), and then pushes them out from there. What do you think? Does it seem like a good solution?

Thanks,
Michael
Photo of Evan Martinez

Evan Martinez, Community Manager

  • 9,264 Points 5k badge 2x thumb
Hi Michael,

You would still import your data same as always, all I'm suggesting you change is how the data is transmitted out of Quick Base to your external service. Essentially the AddRecord call will only catch a single record change when multiple records are added. The ImportFromCSV call would only be a change in your webhook, it essentially would change the webhook to let it know to capture and pass out each record added via an import to your external service. It just happens to format that as a CSV file.

Alternatively, it is possible to write a script that is more robust then the webhooks, as the issue with webhooks is they fire once off of those actions taking place. So that single Add Record happens on Record 1 and finished, while CSV will scoop up all the records you add. 
Photo of Keith

Keith, Champion

  • 1,020 Points 1k badge 2x thumb
Michael
did you try to change your web hook to use API_ImportFromCSV instead of API_AddRecord?
Here's a sample...





Keith
Photo of Michael

Michael

  • 160 Points 100 badge 2x thumb
Hi Keith & Evan,
Thanks for the suggestions. I'll pass these along to my developer and see if he can make it work.
Best,
Michael
Photo of Michael

Michael

  • 160 Points 100 badge 2x thumb
Hi Evan,
Given your suggestion (and Keith's example), is there a way to do this in JSON? The example is with XML. The body of our message is currently just the key:value pairs for data which we send to an external endpoint. What would be the syntax for JSON to implement the looping of the new records (it seems to be %Repeaton% and %Repeatoff% in Keith's example). 
Thanks,
Michael