Skip to main content
Best answer

How to handle multiple HTTP requests to callback URL

  • 26 June 2024
  • 1 reply
  • 21 views

We’re using `z.generateCallbackUrl()` which works great in most cases.
By default, the callback URL is called only once to notify our resource is ready.

The problem is that our users can enable a feature, and it will send two HTTP requests to the callback URL, because two different resources are created that take a long time. (Yes, this is poor API design, but that’s not possible to change)

For our action, I’m only interested in one of the HTTP requests, but I’m receiving the wrong HTTP request which doesn’t have the correct information to return to our users.

 

Our ideal solution would be that `performResume` can be triggered multiple times, and we can tell Zapier to wait for the other HTTP request, and ignore the current one. Something like this imaginary code:
```
const performResume = async (z: ZObject, bundle: Bundle) => {
  // determine if request is the one we are not interested in
  if("some_property" in bundle.cleanedRequest) return z.ignorePerformResume();

  // continue doing stuff
};
```

1 reply

Userlevel 3
Badge +3

Hi @niels-aai 

The performResume can only be run once per Zap run and it would run immediately it receives an HTTP request at the callback URL.

You could implement some sort of functionality in your application where the multiple HTTP requests could be consolidated (and sent to an internal endpoint) before sending a final request to the callback URL. That way, the callback URL would only receive 1 HTTP request and it would be the final one sent by your API.

But if it comes to the performResume not running when it receives a request (or ignoring a request), that is currently not possible.

Hope that helps.

Reply