The new Oracle APEX 24.2 brings with it new Enhancements to the REST Data Sources Shared Component. The following is a summary of the new enhancements:

  • Support for Token-Based pagination in “Simple HTTP” REST Data Sources
  • Support “Order By NULL” clauses when pushing down Sort predicates to a REST Source of the “ORDS” type
  • Flexible Remote Server
  • Setting Scope for Web Credentials programmatically

 In this blog post, we will explore them.

 

Support for Token-Based in “Simple HTTP” REST Data Sources

Some APIs support token-based pagination. Token-based pagination relies on an opaque string, typically called a token or cursor, which acts as a pointer to the next page of results. This token is included in the JSON response and is passed as a URL parameter in the next API request to retrieve subsequent results. 

The following is a sample token-based pagination REST API. It uses cursor and nextCursor for token-based pagination.

 

Token Based Pagination Rest

If you create a REST Data Source of a type “Simple HTTP” for the previously shown token-based pagination REST API, that Data Source type now supports REST services with token-based pagination, enhancing integration with APIs that use this pagination scheme.

You will notice a new Pagination Type called “Page Size and Page Token” where you can define values for the following parameters:

  • Page Size URL Parameter
  • Page Token URL Parameter
  • Next Page Token Selector

Token Based Pagination Simple HTTP

Now, you could use that REST Data Source, for instance, as a source for an Interactive Report component, and navigation would work seamlessly. 

 

Support “Order By NULL” clauses when pushing down Sort predicates to a REST Source of the “ORDS” type

Oracle APEX 24.2 now supports “ORDS By NULL” clauses when pushing down Sort predicates to a REST Source of the “ORDS” type. This feature requires ORDS 22.4 and higher. 

This property specifies how NULLs are treated for sorting.

 

Available options include:

  • Nulls are Highest In ascending order, NULLs appear last. In descending order, NULLs appear first.
  • The other option is Flexible. This option is only supported for REST Data Sources provided by ORDS version 22.4 or higher.

Soring Nulls - Flexible

 

For instance, if you select Flexible for your REST Data Source and use it in an Interactive Report, you will see a new Null Sorting column under the Sort option. This feature allows you to push either “Nulls Always Last” or “Nulls Always First” predicates to ORDS regardless of whether the sorting is in Ascending or Descending order.

IR Sorting Nulls

 

Flexible Remote Server

Oracle APEX introduces Flexible Remote Servers, allowing dynamic configuration of server endpoints for REST Data Sources and REST Enabled SQL references at runtime. This feature enhances flexibility by enabling applications to adjust Remote Server URLs dynamically based on user or environment-specific requirements. You can easily derive the Base URL of a Remote Server object (used for REST Data Sources, REST Enabled SQL, Authentication) dynamically with a PL/SQL Configuration procedure having APEX invoke totally dynamic endpoints based on current app, tenant or environment settings.

The feature includes two key highlights

  • Dynamic URL Substitution: Allows runtime substitutions in the Remote Server URL using parameters defined in a configuration procedure.
  • Configuration Procedure: Enables developers to define a PL/SQL procedure or anonymous block for generating substitution parameters dynamically.

Example – Dynamic URL Substitution

The Remote Server URL can contain substitution parameters, allowing dynamic values at runtime:

https://#host#:#port#/ords/#tenant#/api

 

Substitution parameters like #host#, #port#, and #tenant# can be dynamically updated based on runtime settings.

Example – Configuration Procedure

Here’s an example of a PL/SQL Configuration Procedure:

procedure configure_remote_server( 
                    p_info IN apex_plugin.t_remote_server_info,
                    p_config OUT apex_plugin.t_remote_server_config
)
IS
BEGIN
    p_config.base_url := 'https://#host#:#port#/ords/#workspace#/#api#';
    p_config.substitutions := apex_t_varchar2();
    apex_string.plist_put(p_config.substitutions, 'host', v('P65_HOSTNAME'));
    apex_string.plist_put(p_config.substitutions, 'port', v('P65_PORT'));
    apex_string.plist_put(p_config.substitutions, 'workspace', v('P65_WORKSPACE'));
    apex_string.plist_put(p_config.substitutions, 'api', v('P65_API'));
END;            

Flexible Remote Server Configuration

 

Setting Scope for Web Credentials programmatically

“Scope” of a Web Credential can now be set programmatically using the APEX_CREDENTIAL API. 

As an example, if you have a Web Credential with a Static ID called ‘oauth_web_creds’ the developer could use the following PL/SQL code to set the Scope programmatically to have user:read permission:

begin
    apex_credential.set_scope (
        p_credential_static_id => 'oauth_web_creds',
        p_scope                => 'user:read' );
end;

 

Conclusion

From supporting token-based pagination to supporting “Order By Null” clauses pushing down Sort predicates to a REST Source of the “ORDS” type to providing the ability to have a Flexible Remote Server to Setting Scope for Web Credentials programmatically, Oracle APEX 24.2 keeps adding more features to your shared REST Data Sources.