Hello, I’m trying to make a request to an API that creates a pdf and then another request that downloads it but I need to add a delay in the actions to it has time to process like 1s any suggestions on how I can do this?
There is usually “pause before next action” but has limitation based on where it is being run. Another way is to schedule a custom event but Type of thing should be relevant to what the api returns
@lukejamison0 You should be able to put a condition on your download step that says ‘Only when the result of step 1 is not empty’. This will force the Bubble to delay firing that action until the first action (creating the pdf) is completed so that Bubble can determine whether or not it is empty.
Alternatively, I assume the call that creates the PDF is returning identifying data you can use in your call to download. If so (and this is the better way to do it) simply make the step that downloads the pdf dependent on the step that creates it.
I.e. Download the pdf where ‘ID = Result of step 1’s ID’
Check out my reply in this post. I didn’t need to make a pause with my API. Maybe this one will help?
@eli thanks for the suggestion but its still not working. Basically i use one endpoint to create the file and then another to endpoint the retrieve the file so i put the filter on the retrieve file part and that’s the one the would have the URL to the file and it still doesn’t have enough time to process
@boston85719 i believe thats only for elements not actions that GET and CREATE data
What service are you using? It’s unusual that you would need to make a second call to retrieve the pdf as it should be returned in some form on the create call.
@eli Its a company called Detrack. I can share there API docs.
Ok, so not a PDF only service, that makes more sense. If you have it working and just need a delay you can do that by using Schedule an API workflow under custom events as your second step:
Set it to how many seconds you need to delay it.
@eli Okay great i’ll try that. How to i Create that scheduled API workflow.
@eli How can i get the data from the Scheduled api workflow back to the other workflow?
This will get you started: https://youtu.be/zoPCX34Y8Io
@eli I can’t seem to find where they get the data back into the workflow that kicked off the Scheduled api workflow. Do you have any suggestions?
Why do you need it back in the same workflow? You have another workflow running, continue the process there.
I’ve gotta run. You have a couple options to do what you initially asked. Here is a link to the manual on Scheduled workflows: https://manual.bubble.io/using-the-bubble-api/scheduled-workflows.html
My screen shot is from the workflows editor, where we create actions…the navigate add pause is an action to pause and wait before the next action in the set of actions that makes up the workflows is triggered
So if you simply want to add a pause before another action starts, that is the way to do it
Any action that the navigate pause is used in front of will have the “delay” set in the navigate pause workflow action before the action is triggered. So if you want to add a pause before the action of retrieving data is triggered or the action to create data is triggered, or even to scroll to a position on page ( basically all actions ) then it will work if you just want to add a delay of 1 second as that is what it is used for.
@boston85719 Thanks for the reply so i tried it out for 3 seconds and still no luck. 3 seconds should be plenty on time for it to process so no idea why its not. Here is a screen shot of what it have. If you have any other suggestions i would love the help
That is because the pause is between two api workflows.
The api workflow will trigger in the above workflow, then the pause will trigger
The issue is that the api workflow triggered in the first step, doesn’t have to finish before the pause in step 2 gets triggered…the api workflow in step 1 only needs to start before the pause in step 2 is triggered.
If your api workflow is straightforward, I think what @eli had been mentioning of scheduling an api workflow.
In you create api workflow at the end schedule the retrieve api workflow and schedule with a delay as eli mentioned.
Otherwise you may want to investigate a way to “time” the create export api workflow.
But why do you need to create a pdf and then download it? Wouldn’t the created pdf already be stored in you file manager and be able to retrieve it from there? I thought when we create files in bubble, they are already stored in the file manager.
@boston85719 So I’m using an API from another company. To create the PDF I want I have to send a Request to create the file so a POST request with some JSON data such as the date. Then to get the file I have to make a GET request with the ID at the end of the URL from the create Request. Then In the GET request, it returns a URL the file. And I want to take that URL and send it to a Link on a page so that when it’s clicked it opens the file in a new tab. I have attached a workflow diagram.
There are plugins built for bubble that create a pdf…you might want to use one of those if the pdf you are creating is using data and objects from your bubble app; would make the whole thing simpler