31
Views
6
Comments
How can I copy a REST API from one Application to another one.

Hi, I'm trying to use the same API I'm using in application A on application B. I copied this API and pasted it into application B but whenever I use it it crashes. Any idea?

Hi,

You want to use same API in two different application right?

Below is the suggestion:

1. You can create one Application with service module and consume API in it and create one server action for that API. 

2. That action you can use in any application by taking dependency.

Hope this will help you!!!

Thanks

Ruchi

Are you trying to copy a SOAP API?
Anyways, I think your best option is to import the definitions again of the API in the new module instead of copy pasting. (especially if it is a SOAP)

For SOAP it would be importing the WSDL and for rest you could use the swagger to import all the required methods if needed.
Also, look at the Event logs of windows, it might give you some insight on what error occured on the application. And you could send them to OutSystems so they can improve their IDE if it's a bug in the IDE.

Hi,

You can consume API in one module B with module type as service and then through manage dependencies take it other module A.

Attaching the oml for your reference consume API(B) in which API is consumed and API in which i have taken dependency.

Please look it might be helpful as per your requirement.

ConsumeAPI.oml
API.oml
Champion

Hi Pedro,

The best way to create one service module as suggested by other members but still you want to copy the same api in application B then make sure you copied everything like api structure and and site property if used for api configuration values.

Or you can debug both the api for comparison here you can identify what passing wrong in copied api.

Regards,

Arun

Hi Pedro,

REST APIs cannot "crash". What is the exact behaviour you are witnessing? Also, I assume this is a REST consume (not an expose)? So you are consuming the API? Did you check the Integration Logging (and don't forget to increase the log level)? What exact errors are you getting? Might it be possible the API uses a Site Property that doesn't have the correct value in the new module?

Regardless of all this, like some already suggested, the correct way would be to have an integration module that consume the REST API, and exposes a Server Action that functions as a wrapper to the API. You can then call the Server Action from multiple modules, and centralize the REST API (so if e.g. the URL changes, you only need to change it once).

Hi,

You need to isolate your API in a seperate module and expose the methods via public sever actions.

This way you avoid duplicate code and duplicate consumptions of AOs (Application objects) in your OutSystems license.

Each consumed API method counts as 1 AO.

Regards,

Daniel 

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