25.17 EXECUTE_REST_SOURCE Procedure Signature 1
This procedure executes a REST Source operation based on module name, operation, and URL pattern (if required). Use the t_parameters array to pass in values for declared REST Data Source parameters. REST Source invocation is based on metadata defined in Shared Components.
                  
Syntax
APEX_EXEC.EXECUTE_REST_SOURCE (
    p_static_id     IN      VARCHAR2,
    p_operation     IN      VARCHAR2,
    p_url_pattern   IN      VARCHAR2 DEFAULT NULL,
    p_parameters    IN OUT  t_parameters );Parameters
| Parameter | Description | 
|---|---|
p_static_id | 
                              Static ID of the REST Data Source. | 
p_operation | 
                              Name of the operation (for example, POST, GET, DELETE). | 
p_url_pattern | 
                              If multiple operations with the same name exist, specify the URL pattern, as defined in Shared Components, to identify the REST Source operation. | 
p_parameters | 
                              
                                  Parameter values to pass to the external REST Data Source. Note that HTTP Headers, URL Patterns and other parameters being passed to a REST Data Source are typically strings. Oracle recommends that you explicitly pass all values to   | 
                           
t_parameters | 
                              Array with OUT parameter values, received from the REST Data Source.
                               | 
                           
Returns
| Return | Description | 
|---|---|
p_parameters | 
                              Array with OUT parameter values, received from the REST Data Source.
                               | 
                           
Example
This example assumes a REST service being created on the EMP table using ORDS and the "Auto-REST" feature (ORDS.ENABLE_OBJECT). Then a REST Data Source for this REST service is being created in Shared Components as "ORDS EMP."
The POST operation has the following "Request Body Template" defined:
{"empno": "#EMPNO#", "ename": "#ENAME#", "job": "#JOB#", "sal": #SAL#}Parameters are defined as follows:
| Name | Direction | Type | Default Value | 
|---|---|---|---|
EMPNO | 
                              IN | Request Body | n/a | 
ENAME | 
                              IN | Request Body | n/a | 
SAL | 
                              IN | Request Body | n/a | 
JOB | 
                              IN | Request Body | n/a | 
RESPONSE | 
                              OUT | Request Body | n/a | 
Content-Type | 
                              IN | HTTP Header | application/json | 
PL/SQL code to invoke that REST Source operation looks as follows:
DECLARE
    l_params apex_exec.t_parameters;
BEGIN
    apex_exec.add_parameter( l_params, 'ENAME', :P2_ENAME );
    apex_exec.add_parameter( l_params, 'EMPNO', :P2_EMPNO );
    apex_exec.add_parameter( l_params, 'SAL',   :P2_SAL   );
    apex_exec.add_parameter( l_params, 'JOB',   :P2_JOB   );
    apex_exec.execute_rest_source(
        p_static_id        => 'ORDS_EMP',
        p_operation        => 'POST',
        p_parameters       => l_params );
    :P2_RESPONSE := apex_exec.get_parameter_clob(l_params,'RESPONSE');
END;Parent topic: APEX_EXEC