How to make repeated API call until response changes from "generating" to "success"?

Hello dear bubblers,

I am sending data over to to generate a beautiful pdf. To generate a pdf it takes something around 10 Seconds. Since there is no API-delay function or a way, to make a while-loop I am asking myself how I can handle this problem?

The response from pdfmonkey has a “status” parameter, which is first “generating” and changes to “success” as soon as the document generation has finished.

I am sending two requests:
POST - to post the dynamic data and start generation of the document
→ the response keeps the ID of the freshly generating document
GET {ID} - to actually receive the documents download link
→ in the first few seconds the response for status will also be “generating”.

I don’t want to make an artificial delay since this is not reliable.

What can I do? How can I repeat the GET request and wait for the status to change?

Thank you!

You should use webhook.
This will send a request to a backend WF when this will be done.
So you should create a DB thing to store the ID from pdfmonkey and when you will get the webhook, you will find this item using ID and update with the file.

1 Like

Thank you very much! Could you elaborate a little bit?

What is “WF”?

Where should I receive the webhook? Sure I could use Svix as a service but I am not sure if you meant this? Should I create another bubble application to handle this?

WF - Workflow
Go in your settings tab, API and activate Backend WF
Now in the page menu dropdown (top left) you will see “backend Workflows”. Click on that.
Add an API Workflow and use Detect request data in parameter definition. Click on detect data and this will give you a temp link. Use this link and trigger the webhook a first time (so send a request to generate a PDF and wait the webhook).
When this is done, save the paylod and modify the webhook in pdfmonkey (remove /initialize)
The webhook is related to the version. If you cannot add more than 1 webhook, you will need to remove version-test/ when ready to go live


Thank you very much! I did not know about this backend workflow. Your answer solved many questions of mine - thanks a lot!

1 Like