Oracle APEX 23 Course For Beginners

Oracle APEX 23 Course For Beginners
Oracle APEX 23 Course For Beginners

Sunday, 4 June 2023

How To Create RESTFUL DATA SOURCE Module In Oracle APEX

In this blog post, you will fetch the latest currency exchange rates from a remote server using the Oracle APEX RESTFUL Data Source utility. Restful Data Source Modules act as a reference to one or multiple external restful services. A module can contain one or many restful data Source Operations which are the references to a concrete external restful service. Restful Data Source Modules enable developers to access Representational State Transfer (REST) services or generic JSON data feeds in applications and use the data in Application Express components such as interactive reports and interactive grids. Unlike existing restful Service References, a Restful Data Source Module contains metadata about the restful service which can be used by Application Express Components or PL/SQL processes to invoke the service and to process the responses.

Fetch Data from an External Restful Data Source

First, you will learn how to integrate data from an external restful data source into your APEX application. You will integrate the latest currency exchange rates and currency conversions into your APEX application by using a free currency API from the amdoren.com site. This currency API is available in JSON format and easily accessible through a simple API request over a secure HTTPS connection. Here are the steps to accomplish this task:

1.       Go to https://www.amdoren.com/currency-api/.

2.       Click the Free Sign up! button

3.       Enter your credentials including your e-mail address on the Developer Sign-Up page and click the Sign-Up button. You'll get a message "Your account has been created. Please check your email for your account details."

4.       Open your email client and write down the password received from hello@amdoren.com. 

5.       Access the website using https://www.amdoren.com/developer/ and log in to the Developer area by entering your email ID and the password you received in your email. 

6.       After successfully logging in to your account, you will see your API key. Write down this key as well. 

7.       In APEX, go to Shared Components \ Restful Data Source Modules (under Data Sources) and click the Create button. 

8.       On the Method screen, select the From scratch option to create the restful data source module from scratch and click Next.

9.       On the General screen, select Simple HTTP for the restful data Source Type and enter Currency Converter for the restful data Source Name. Enter https://www.amdoren.com/api/currency.php for URL Endpoint, which is the base URL for the currency API. Click Next.


10.   Accepting the values on the Remote Server screen, click Next. The Base URL is the URL of the chosen Remote Server object. The HTTP Endpoint URL of this restful data source module is made up of the Base URL and the service-specific path suffix, which appears in the Service URL Path underneath. The HTTP Endpoint URL is built by appending a service-specific URL Path to the Base URL specified in the Remote Server object.


11.    Select No for Authentication Required and click the Advanced button on the Authentication page to add some parameters.

12.      On the Parameters screen, enter values as shown in the following figure and click the Discover button. Paste the API Key value you got in step 6 in the Value box next to the api_key parameter. The Preview screen will come up displaying a value in the Amount column under the Data tab. The Data Profile tab contains columns and type definitions. Click the Create Rest Data Source button to complete this process.

13.       Create a static List of Values named CURRENCIES as shown in the following figure. The values used in this LOV will be used in two Select Lists on the application page created next.


14.       Create a Blank page and name it Currency Converter.

15.       Add a region named Parameters to this new page.

16.       Add the following three items to the Parameters region.

Property

Item Value

Item Value

Item Value

Name

P4_FROM

P4_TO

P4_AMOUNT

Type

Select List

Select List

Text Field

Label

From Currency

To Currency

Amount

List of Values Type

Shared Components

Shared Components

-

List of Values 

CURRENCIES

CURRENCIES

-

17.       Add a Classic Report region to the page with the following attributes:

Property

Value

Title

Current Rate

Type

Classic Report

Location

Web Source

Module

Currency Converter

18.    Expand the Parameters sub-region under the Current Rate Classic Report region. The region contains the three parameters you defined while creating the Rest Data Source module. At this stage, the parameters exist with the same values you defined in Step 12. In order to make the module more flexible, you need to replace these static values with the values you select through the three parameters created in step 16. Click the Amount parameter, set its Type to Item, and Item to P4_AMOUNT to map this parameter to the value of the P4_AMOUNT text field item. Similarly, change the Type and Item attributes of From and To parameters to P4_FROM and P4_TO, respectively.

19.     Add a new button to the page with the following attributes. After you select your desired currencies and input a value, you hit this button to calculate the conversion amount.

Property

Value

Button Name

CALCULATE

Label

Calculate

Region

Parameters

Button Position

Copy

Action

Submit Page

20.     Save and run the page. Select different currencies using the From and To select lists, enter some value in the Amount text field and hit Calculate. The API specified in the Restful Data Source module will perform real-time conversion and will display the exchange rate in the Amount column, as shown in Figure 6.


For Visual Instruction Watch This Video

Display Data Dynamically In A Gauge Chart

In this tutorial, we will learn how to display customer's ordered data in a gauge chart dynamically. As you choose a customer name from ...