Consume REST URL from Local variable

Consume REST URL from Local variable

  

Hi,


My REST API URL is different for all the environments i.e. Development, Staging, Production.

Hence I want to consume REST URL from Site Property variable or so, which should be configurable.


Please guide me in this regards, as REST is not accepting anything part from http address.

Regards,

Hemlata

Solution

Hi Hemlata,

You can change the REST API URL for an environment in the Service Center management console, which overrides the default URL you defined in your module.

Check this documentation topic for the instructions.

Hope it helps! 

Solution

Cláudia Carpinteiro wrote:

Hi Hemlata,

You can change the REST API URL for an environment in the Service Center management console, which overrides the default URL you defined in your module.

Check this documentation topic for the instructions.

Hope it helps! 

Thank you!!! 


Hello,

The given solution works if you are using multiple OutSystems environments like dev, test and production.

I have an application that can connect to my acceptance environment as well as to my production enviroment. Now I have defined the REST api twice, once for acceptance and once for production.

However, I would like to use a variable like Phase to determine at runtime to which environment my app will connect. Purpose is that the REST api is defined only once. Is this possible?

Regards,

Peter Nijhuis.

Hi Peter, 

You can use On Before Request event to alter the CustomizedRequest.BaseURL variable AFTER the CustomizedRequest = Request assign.

Hi Peter,

Harlin's suggestion is right. 

You have means of dynamically manipulate the REST request, namely the URL.

You can also manipulate other stuff in the request and also in the response. 

Check out this documentation about REST customization with a simple example.


Harlin & Jaime, thanks for your input!

Eventually I solved the problem using the module (thru dependencies) EnhancedWebReferences.SetWebReferenceURL. This does exactly what I want.

Best Regards,

Peter Nijhuis.