Base URL for consumed REST services configurable at runtime
4103
Views
8
Comments
On our RadarOn our Radar
Data & Integrations

The Base URL for consumed REST services should be configurable at runtime:

In some cases (like the JIRA Cloud REST api), the base URL of the web services varies according to the account used to access them. Since the URL is hard-coded in Service Studio (it can be overridden in ServiceCenter but the setting applies to all users accessing the REST api), there is currently no way to configure this based on the tenant being used or the user that logs in. 

Hi Adrian,

You can use the OnBeforeRequest to change the Base URL.

Even though the way I found for it to be dependent on an input variable feels like "cheating", it isn't that hard to achieve.

You can send the desired URL in a custom request header, then in the OnBeforeRequest action you can check for that header and change the URL based on the value.

Even though having it be simpler (or clearer) would be nice.

If the domain name is static (so it doesn't have a subdomain that is variable), you can use URL parameters to dynamically change the path. Also not very nice, but it works.

These 3 ideas are all hacky.  

Using a site property with a proper URL format makes the most sense.  

Everything is a lego block in outsystem, why not use allow Site Property to be used here

Changing the Base URL requires an extra prod-environmental 1 click publish

also what is the point of this screen in service center: I changed the effective URL it did nothing.

We had the same issue where we needed to change the URL of a PUT at runtime.


Changing the Site Property was a bit too expensive, as we regularly used the service.


Another workaround for us was then sending the change we needed to be made to the URL as a Header, that gets pulled through as part of the Request input parameter. 

Then in the OnBeforeRequest, we would take that information, append it to the base URL (or adjust the base URL with the information as required) and then removing that Header item from the list of Headers.

This was suggested in 2017... it is now nearly 2024... "On our Radar"... this should be done already!

I currently use the workaround suggested by a few people in his post, works fine and not an incredible overhead, using onbeforerequest:
1. Add a URL/BASEURL input to the header.
2. Ensure there is a onbeforerequest
3. Inside Onbeforerequest, filter for URL input in the header.
4. assign the base url
5. (optional) clear the url header input.
note: this can also be applied to the URLPath.


I ran into this while having to find a way to integrate with different shops in shopify. The baseurl contains the name of the shop (https://<nameofshop>.shopify.com). So having the option to add a parameter to the base url would have been handy. I know other shopping applications also use this setup to allow their customers to expose an api.