Hi everyone,
i need to consume an API to fetch data in my table. Could anyone please help. i have been trying for some days now but i am yet to figure it out.
Step 1: Create the REST API Service
Step 2: Create the REST API Method
Step 3. Define method functionality.
Step 4: Publish
Your REST API endpoints are accessible after deploying the application.
Here the endpoint will be:
https://<server>/HK_EC_BackOffice/rest/GetProduct
To add some more information.
How to consume API - https://www.youtube.com/watch?v=XZyyER_hPM8
How to expose API - https://www.youtube.com/watch?v=Hd1p3kTVpP4&t=8s
Kind Regards,
Márcio
The links are not working brother
For me the links work without problem.
Muhammed Riyas already explained to you how to consume. The next step is to drag the method that you are consuming to a data action and output the list/record from the method.
I already shared the video but I will share again, https://youtu.be/XZyyER_hPM8?t=278
At the minute 4:38 you will see how to call the method and put in a data action and assign the list to the output, then you are ready to use the data from the data action.
Again, the video is just an example.
hi saif sheikh ,
lets start how to consume ApI in very simple way then we work in big apis.
lets try to consume the API .
1. we need the url of xyz api , i have this (https://catfact.ninja/fact). first Try in any browser ,is it working well or not.
if it returns ({"fact":"A cat's normal pulse is 140-240 beats per minute, with an average of 195.","length":73}) means it is working.
2. lets consume it now.
1. go to Logic tab >> Rest
2. right click and select consume api >> Add single method
3. new API window will open for url , make sure method should be GET and copy the url{https://catfact.ninja/fact}
4. and click on test see the response must be 200/ok
5. click on copy to body. and finish.
6. copy the response for dataaction output.(logic portion is done).
7. now in Interface tab,fetch data action. which is having one output , now copy the response here, and delete the pre output.
8. now follow as given image below and set the values.
9. after that drag and drop the fact to the screen.
10 . at last make one client Action to refresh the dataaction as given in Image.
You are using it well. But there is something you should have done before. You should have isolate the entitys and the api in another module.
Look at this explanation.
https://www.outsystems.com/forums/discussion/72465/it-is-possible-or-how-i-can-use-a-db-from-one-aplication-to-another-aplication/
Hi Saif,
Are you trying to consume a REST or SOAP api?
Is there authentication on the API?
i am trying to Consume an API using rest from scratch
Hello Saif,
Kindly follow this document to consume the rest API.
https://success.outsystems.com/Documentation/11/Extensibility_and_Integration/REST/Consume_REST_APIs/Consume_one_or_more_REST_API_methods
If you need more assistance kindly explain your requirement in detail.
Hi Riyas ,
I hae some test data which needs to be displayed on screen through consume and expose API.I need help with consuming for now.The above link misses the url generation point and hence is not the best source for beginners. Could you please suggestt for alternate solutions.
Hi Riyas,Thank you for your effort, but i need help with consuming and not exposing.Could you please help in a similar way, the way you did it for expose.
Thank you in advance.
Open the Logic tab in your consumer module
open the Integrations folder.
Right-click on the REST element and select Consume REST API
Select preferred consuming method Single/Multiple.
Selected Multiple methods, it will get all the methods inside the specified API end point.
Provide the endpoint URL, which we received from the producer module.
Choose the REST API methods you want to import (by default, all methods) and click Finish.
Now you can view the methods which got it from your producer by consuming the API.
For more details kindly go through the below documents, there are more concepts you need to consider while using APIs like authentication, response validation, etc.
https://success.outsystems.com/Documentation/11/Extensibility_and_Integration/REST
Hi Riyas,Could yo please confirm -from where you got the url for consume
Moreover, you can easily find the URL from the producer module where you define the API
Hi Riyas,I need to display data inside a table using API ( marked in brown)
i have created a expose API (marked rounded Black) using Get method (Get all claim details) ( Marked in black square).Could you help me with what should be my next steps?
Hi Everyone, Márcio Carvalho, @Muhammed Riyas , Daniël Kuhlmann, Sourabh sharma
Created another Expose and Consume based on all your inputs. Could anyone please review it once.
Red marked is expose and Blue marked is consume method
If its correct-Could anyone please help out with instructions to how to display this data inside the table.
Also give inputs about the best practices to be followed while creating API's.
If its incorrect-Please point out where i went wrong.
Attaching .oml file for reference
Just what i was looking for.... Thank you so much.
Hi saif sheikh
lets try to consume the API In Table.
We will use (https://jsonplaceholder.typicode.com/users)
3. new API window will open for url , make sure method should be GET and copy the url(https://jsonplaceholder.typicode.com/users)
6. copy the response for dataAction output.(logic portion is done).
8. Now drag and drop the Table.
9. In the columns drop the expressions ,in it drag & drop the one by one all structure for the output.