Introduction
Testing REST calls in Oracle APEX is a critical part of integrating external data and services into your applications. Before deploying or embedding RESTful services into reports or forms, it's important to validate the response, parameters, and structure to ensure your application handles the data properly. Oracle APEX provides built-in tools to test and debug REST calls through the Web Source Module interface and REST Workshop.
How to Test the APEX REST Call
-
Navigate to Web Source Modules
-
Go to Shared Components > Web Source Modules.
-
Click on the REST module you want to test.
-
You will see the Details, Operations, and Parameters tabs.
-
-
Test with Sample Data
-
In the Web Source Module page, click Test (usually at the top right).
-
Provide required parameter values if any (e.g., path or query parameters like employee_id).
-
Click Test to execute the call.
-
APEX will display the JSON or XML response. You can inspect keys, values, and data structure directly.
-
-
Use REST Workshop for Additional Testing
-
Navigate to SQL Workshop > RESTful Services > RESTful Services.
-
If your service was defined through ORDS (Oracle REST Data Services), you can locate and test it here.
-
Expand the module and click Test next to the desired resource handler (GET, POST, etc.).
-
Enter headers, parameters, and body as needed, then click Send.
-
-
Check Response and Debug Issues
-
Confirm that the HTTP status code is
200 OK
. -
Inspect the returned payload for completeness and correctness.
-
Check for missing or incorrect parameters.
-
If you receive
403
,404
, or500
errors, revisit the endpoint URL, authorization headers, and parameter mapping.
-
-
Test Dynamic Values in a Page
-
On the APEX page using the REST module, enter values in page items that are used as input.
-
Run the page and confirm the REST call reflects the dynamic values and returns expected results.
-
Use Developer Toolbar > Debug mode to track how values are passed into the REST call and inspect any runtime issues.
-
Best Practices
-
Always test REST services in both standalone mode (Web Source Module) and in-page runtime.
-
Validate API key or OAuth2 configuration if you receive authentication errors.
-
Use test values that represent edge cases (e.g., large inputs, nulls, or invalid entries).
-
Log response payloads and status codes using PL/SQL for post-deployment monitoring.
-
Use tools like Postman to test external REST APIs independently before integration.
Oracle APEX Documentation
To test your RESTful service call:
Enter an employee ID in the P1_EMPLOYEE_ID text box.
Trigger the process (e.g., by clicking a button).
Check the output, either in the page item or via the debug output in Oracle APEX.
Step by Step simplest method “Example”
Continuing from the previous section, create a “Module”
Enter the required fields.
Should look something like this:
Go back to the newly created Module
Lets add a handler
This handler will look for the id and return those rows. Add the SQL code below.
Navigating back to the module and slecteting the ID template displays the following
The new “ID” handler should look lik the following two images.
The new handler will display at the bottom of the screen.
Totest the call the Service use the following:
adbnphxadcdev01.adb.us-phoenix-1.oraclecloudapps.com/ords/xxdii_paul_test/airportslist/1
That will return the following from a browser:
Or the text equivalent of:
{"items":[{"id":1,"code":"0AK","name":"Pilot Station Airport","city":"Pilot Station","state":"AK"}],"hasMore":false,"limit":25,"offset":0,"count":1,"links":[{"rel":"self","href":"https://adbnphxadcdev01.adb.us-phoenix-1.oraclecloudapps.com/ords/xxdii_paul_test/airportslist/1"},{"rel":"describedby","href":"https://adbnphxadcdev01.adb.us-phoenix-1.oraclecloudapps.com/ords/xxdii_paul_test/metadata-catalog/airportslist/item"},{"rel":"first","href":"https://adbnphxadcdev01.adb.us-phoenix-1.oraclecloudapps.com/ords/xxdii_paul_test/airportslist/1"}]}
Common Scenarios for REST Synchronization:
Fetching External Data:
You can set up REST synchronization to regularly pull data from an external service (such as a weather API, earthquake data, or social media API) and display it in your APEX application.
Sending Data to External Services:
You can push data from your APEX forms to external systems (e.g., submitting user data to a CRM or payment gateway).
Periodic Synchronization:
Schedule periodic synchronization (e.g., every hour or day) to fetch or send data automatically without user intervention.
REST Synchronization in Oracle APEX: How It Works
Oracle APEX provides multiple ways to synchronize data with external RESTful services:
Web Source Modules:
Web Source modules allow you to connect APEX to RESTful APIs and create Read-only data sources. You can use a Web Source to pull data from the external API and display it in your APEX reports or forms.
Example: If you want to display earthquake data from the USGS API in an APEX report, you would define a Web Source for the API endpoint and map the fields.
Steps to create a Web Source:
Create a Web Source in your APEX application.
Specify the REST API endpoint and request method (GET, POST, etc.).
Define how to parse the JSON or XML response and map it to APEX application columns.
RESTful Web Services in APEX:
APEX allows you to expose RESTful Web Services that can be consumed by external applications or APIs. This is typically used when you want APEX to push data to another system via REST.
APEX provides RESTful Web Service endpoints, and you can define these services to accept or return data in JSON or XML format.
EXAMPLE:
APEX exposes a REST endpoint that an external system can send a POST request to, containing data that will be inserted into your APEX application's database.
Interactive Grid with REST Integration:
You can use an Interactive Grid in APEX to integrate with REST APIs for CRUD operations (Create, Read, Update, Delete). The grid allows users to interact with remote data by making REST calls when records are added, edited, or deleted.
Scheduled Jobs for Periodic Synchronization:
You can set up scheduled jobs in APEX (or Oracle DB) to periodically fetch or push data to external APIs. This can be useful for synchronizing data at regular intervals, without requiring manual intervention.
Using PL/SQL to Interact with REST APIs:
For more custom control over the synchronization process, you can use PL/SQL to interact with RESTful APIs. The UTL_HTTP package in PL/SQL allows you to make HTTP requests to external REST services. You can use this to fetch data and then insert/update it in APEX.
Conclusion
Testing REST calls in Oracle APEX ensures your application integrates external services reliably and securely. By leveraging Web Source Modules, REST Workshop, and runtime debugging, developers can validate each part of the REST call lifecycle. A well-tested REST integration leads to more stable, responsive, and maintainable APEX applications.
No comments:
Post a Comment