Hello,
I have fetched data via a REST API, specifically profiles from another website, and processed this data into a table. This part works fine. Now, I want to ensure that when I create a new profile or update an existing profile on the website, these changes are automatically reflected in my application. I have tried various approaches, but I can't seem to get it to work. What am I missing? How can I ensure that the table automatically shows the updated data?
Thank you in advance!
One option to consider is exposing a REST endpoint on your website so that when the other site updates or creates a profile, they can notify you. This way, you can retrieve the updated data from the other site and update your table. This is only possible if you can modify the other site to invoke your API.
By the way, what approaches have you tried so far, and what challenges are you facing?
Hi @Siya, thanks for the response. I just have a GET URL, i can't change anything on the other site. I looked on the forum to find some solution, and find server actions to call the API again and also client actions etc.
I also just removed the API and start over again, but then i also get the old items. So i don't know what i'm doing wrong.
As I understand from your response to @Nawaz Khan, your requirement is to fetch the data using an API only when an Admin access a particular screen. You can use Data Action, as suggested by @Nawaz Khan, to fetch the data and update the entity. Regarding your question about Swagger, can you consume the API in a test application to see the exact issue?
Fully agree with Siya, I think that is the best option available.
if the solution which @Siya suggested not fit as per your requirement due to not having control over the other party to consume your API to notify you when change occurs in profile then my opinion you have the timers option which can check periodically and update your table.
Hi @Nawaz Khan, Also thanks for the reply with a solution, and yes i can't change anything. Is there no option, that on 'OnInitialize' there will be a API call to refresh?
@David Castro yes you can use the DataAction of page instead oninitialize client action and get the logged in user detail and update in your DB. More appropriate use will be when user login first time and if login successful then you should call the API to update the user record. Please note that this case is suitable if the API you are consuming can respond you with data as per the logged in user while if consumed API is returning the list of all users regardless of current user(assuming the API cannot return single user) then timer is the best option to update automatically without any user interaction.
Hope this will help
@Nawaz Khan thanks again for the reply.
The data in question is a list that does not need to be user-specific. The main requirement is that when the "admin" logs in to manage this data, they should immediately see an updated table.
I recently tried to manually refresh the API, but I received the following error message: "We weren’t able to import the Swagger file since it doesn’t follow a supported specification."
Am I doing something wrong?
Hi David,Can you share the OML. It Will be more productive to help.
About the swagger... How did you first get this endpoint?
@David Castro most probably the API you refreshed was added as single method which does not required Swagger specification and you can define the request and response objects as per the API specification. It might be due to the API you consumed does not have the Swagger documentation. Unlike Outsystems, any other platform like .NET, swagger specification required to add separately and may not be available.
you can check how to add the API as per the swagger specification here
Hi @Jean Bastos, Yes i will upload it now, i removed the actions i tried.
You can call your API in data action to get updated record
Regards
Shradha
Hi @Shradha Rawlani,
Thanks for the reply, can you explain this?
Kind regards, David
Hi David,
Sure,
It will give you updated record based on updated
Hi @Shradha Rawlani, I don't have the possibility to modify the API after Save of Update.
Thanks,
Hi David
Records that are updated or created are stored in Database or update the API by API update action?
@David Castro, there must be some parameters which you must be using to filter the specific record (DOB, Civil Number, License number, Passport number etc) in order to update in your DB after getting the record from the API.
As per you attached .oml file, It seems you do not have any relation between the users and the API response if I am not wrong. First please define the relation DB users and API response and that relation will identify the record required to update in your DB.
Hi @Nawaz Khan, thanks for the respond. The only link i get from the GET is the one you can see in the file. So so you think i cant get the table updated?
@David Castro I think no, you can't update your DB.
Only way is if you have some identical fields in your DB and in API to match the record to update.
Hi @Nawaz Khan, The thing is, sometimes when i made a change in de other website on a profile, i see the updates in outsytems and then i try to do more i don't. The fields are identical, i imported the GET and insert the fields from out the structure in outsystems. I dont understand why some are working and some not. I insert all the info in the form on the other website and some i showing in Outsystems table like the screenshot and some not.
This is just a try out, i can only start building the app when this works instant, i just don't get it.