68
Views
5
Comments
Solved
Share Consumed REST APIs between two applications
Application Type
Mobile, Reactive, Service
Service Studio Version
11.54.20 (Build 62656)

Let's say I have the following scenario

Application 1: MyApp.Web (Reactive Web App)
Application 2: MyApp.Mobile (Phone App)
Application 3: MyApp.Data (Service)

I want to have a web and a mobile app both communicating with an existing software that exposes a rest api.

My idea is that I consume the rest api in MyApp.Data and add this as a dependency in MyApp.Web and MyApp.Mobile

However, in the "Manages Dependencies" window I don't see the rest api methods.

I figured out that I can create a new server action, use the same in and out parameters and just call the rest method and reassign the values. Basically just a wrapper.


Is this the recommanded approach? It seems like some unnecessary extra steps. Is this the recommended approach? Or is there a better way?

UserImage.jpg
vikas sharma
Champion
Solution

Hi Jurgen,

From above suggestions now its clear that you can expose server actions which will call the rest API and take dependency of this server action in your consumer modules. This approach have many advantages.

Here want to add one small suggestion, instead of server actions you can go with service actions. So that your consumers will be loosely coupled with the APIs.

regards


UserImage.jpg
Jürgen Steinblock

Yes, using a service action is a good advice, thanks.

2025-12-17 21-10-06
Shlok Agrawal

Hey Jürgen Steinblock

Please try to understand API and server action are 2 different things.
If you make a server action public it can be used in another module. And can be viewed in dependency. If you consume an API made in another module and consume it in another module, the consummer doesn't know its a action mede in Outsystems, consume Rest APi will treat this Exposed APi same way as it does to any other URL.

But when you expose an API its not a server action, its can be used using the consume API option. On surface level I can say any other API exposed via any technology and API made with help of Outsystems for both the consumption process will be same via URL.

Thanks 
Shlok Agrawal

2023-03-16 16-29-51
Paulo Rosário

Hello Jürgen,

Yes, that is the recommended way. An API  by itself cannot be set to "Public", you could call the same REST in both apps but that would be against best practices toom because you would have duplicate code.

By encapsulating your API call in a public server action you will be able to consume it in both the Reacti app and mobile app without directly exposing the API itself. Imagine it like a CreateOrUpdate but for an API. 

This also allows you more control over your call, like adding some verifications, and so on. 

Hope it helps!

Paulo Rosário

 


2021-03-05 13-56-11
Ricardo Pereira
 
MVP

Hi,

Yes, you can use the "wrapper" approach. It's a good practice because it make the code reusable. It's an extra step that provide to centralize your functionality and to hide some kind of complexity from the integration itself. You can even customize your inputs and outputs to be more human comprehensive.

You can check for a similar case in here:

https://www.outsystems.com/forums/discussion/83973/consume-rest-api-in-seprate-module-and-use-that-api-in-core-module/


Hope this can help you.


Best regards,

Ricardo

UserImage.jpg
vikas sharma
Champion
Solution

Hi Jurgen,

From above suggestions now its clear that you can expose server actions which will call the rest API and take dependency of this server action in your consumer modules. This approach have many advantages.

Here want to add one small suggestion, instead of server actions you can go with service actions. So that your consumers will be loosely coupled with the APIs.

regards


UserImage.jpg
Jürgen Steinblock

Yes, using a service action is a good advice, thanks.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.