18.4.7.7 Best Practices for Configuring REST Service Base URL

Learn about best practices for configuring REST Service Base URL.

When you build an APEX application, it's common to use distinct development and production environments. When that application makes use of a REST Data Source, you will often want it to use a different REST endpoint URL in DEV than in PROD. This lets you test your app in development without disturbing production end users or production data. The APEX Remote Server feature makes it easy to accommodate this usage pattern when working with REST Data Sources, including Oracle Cloud SaaS application REST Data Sources.

When defining a REST Data Source, you provide the Endpoint URL. APEX manages this URL value as a two-part string. The leading part is the Base URL and it comes from a particular Remote Server definition. The trailing part of the Endpoint URL is the Service URL Path. It's important to understand this concept because APEX makes it easy to change the value of the Remote Server Base URL when you deploy your app to a different environment. The value of the Remote Server Base URL stays sticky to the target deployment environment so you can easily deploy updated version of your app from DEV to PROD and the Remote Server Base URL definition in PROD stays how you configured it for PROD.

Study the URLs of the REST endpoints you need to work with, and how they need to change when switching between DEV and PROD environments. This lets you decide where to split the Endpoint URLs into a changeable Base URL part and the static Service URL Path that is the same in both environments. While running the Create REST Data Source Wizard, on the Remote Server step you can adjust the Remote Server and Service URL Path so the remote server's Base URL encapsulates the leading half of the REST service's endpoint URL that needs to change when deploying your application to another APEX instance. You can then adjust the Service URL Path to retain the trailing half of the service's endpoint URL that will always stay the same across deployments. You can also always adjust how a REST Data Source's endpoint URL is split between base URL and service path URL at a later time, too.