Forum Academy Marketplace Showcase Pricing Features

Refresh RG displaying GET API Call after successful POST API Call to same data source

Hi there,

I have a RG that displays data from a GET API Call.

I have a button on that page that creates a new record in the remote data source using the POST Api Call. When this action is completed, the page does not display the new record. I have tried to use “Element Action / Repeating Group / Display Data” in the workflow to send the data again to the RG but this does not work. I have solved it by using the “Navigation / Refresh the page” step in the workflow but this is slow and thinking this is not the best way to do it.

Any sugestions on a better way to do this?

Many thanks

Frank

Hey Frank,

Can you screen shot the datasource from the RG? Also, is the API set to Data or Action?

Thanks Dave,

The GET Call is set to Data
The POST Call is set to Action.

Here are some screen shots:

The RG
image

The Workflow
image

Using The Workflow to re-load the data - which did not work
image
image

Cheers

Frank

Oh I see. Here’s the issue: the GET Call only happens once, Bubble is going to cache the response to that call so even though the data changes Bubble won’t ask for it again. If you add a “header” field to the API that isn’t needed by the API, like an extra date field, or a random number, then when you display the list again via that Action and change the random number, the API response should update.

2 Likes

I guess you can also use reset data but didn’t test this

That’s clever.

1 Like

Thank you!
I tested this with

  • reset relevant inputs and
  • Reset a group/popups
    neither work

image

Thank you anyway

Thanks David,

I have added the header ‘random’ as shown
image

then generating random string as shown in the RG get data
image
and
image

but it did not work.

I am not sure if I have followed the process that you have recomended so let me know where I may have gone wrong.

Thanks agfain

Frank

Sorry. I say REset, but should say Clear list:
screenshot-bubble.io-2020.05.14-00_22_23

You can also use display list

Dave,

changed to current date/time and it worked and super smooth too.

image

Cheers

Frank

thank you - yes, that also worked

I cleared list and the displayed list and it was nice and smooth

Thank you!

Cheers

Frank

2 Likes

Yeah, the goal was to put a changing piece of data so that every time it was requests bubble things the api call was different. When you added the “is empty” to the end of the generator it was always false, so the value actually never changed even though the random number did.

@david17 @frankstillone @Jici

I am just starting to play around with APIs and have things setup to test this approach and feel as if I must be doing something wrong.

When I use the approach from @david17 to have a Date parameter in the header and subsequently follow the workflow actions to display data in the RG with the header set to ‘current date/time’ the refresh of my RG works, but only once.

When I use the approach from @jici to clear the list and then to display the list again, this also works, but only once.

I then tried to use the random number in a header, and that doesn’t work at all.

In the first two approaches that work, but only once, if after I run the workflows for the second time and do a page refresh the new data appears.

Is there something that I am missing to make the RG refresh every time or is it something that actually only works once?

I tried to add a one second pause between the action to create data in the API and displaying the data in the RG using the GET call, but that didn’t help.

Through all the testing I only ever once saw the RG data get refreshed twice (ie: workflow ran twice without a page refresh) but it failed to do it a 3rd time and every other test remained with only 1 instance of the RG data getting updated.

Can you share your setting when it refresh once?

If I focus on just the current date and time in the Header method


And then if I use the clear list and display list method

Screen Shot 2021-03-29 at 7.01.11 PM

Did you test using step by step to check what happen?

Yes…In step by step mode it runs through the steps correctly, but it still only has the RG updated once.

If you can make your app in public view mode and share your editor link, maybe we can have a look and try to find why it’s not working. For me both way work correctly.
did you check also for API Limitations? (# of calls you can do each seconds for example).

The API is just set up between two of my bubble apps as I am just trying to get a grasp on how APIs work generally, so unless Bubble puts some API limitation by default, I don’t believe there would be any reason a limitation would cause it to not update unless there are settings in the app for this.

Here is a link to the editor

On preview mode would need username and password which are username and password

Here is screen shot from the preview page.

The create Via API button is what will trigger the creation and the updating of the RG

First the ‘Input SSN’ will need some number then press encrypt button…once it is in encrypted (second input will display it) then can press the create Via API button.

The RG above the grey container has the API Get response results and the count above it SSN API is the count of the results, which in screen shot shows 14.

1 Like