33.28 MAKE_REST_REQUEST Procedure Signature 1

This procedure performs the actual REST request (HTTP). Unlike a direct invocation of APEX_WEB_SERVICE.MAKE_REST_REQUEST, this procedure respects all REST Data Source parameters.

Syntax

APEX_PLUGIN_UTIL.MAKE_REST_REQUEST (
    p_web_source_operation IN            wwv_flow_plugin_api.t_web_source_operation,
    p_request_body         IN            CLOB    DEFAULT NULL,
    p_bypass_cache         IN            BOOLEAN DEFAULT FALSE,
    --
    p_time_budget          IN OUT NOCOPY NUMBER,
    --
    p_response             IN OUT NOCOPY CLOB,
    p_response_parameters  IN OUT NOCOPY wwv_flow_plugin_api.t_web_source_parameters );

Parameters

Table 33-41 APEX_PLUGIN_UTIL.MAKE_REST_REQUEST Parameters

Parameter Description
p_web_source_operation Plug-In meta data for the REST Data Source operation.
p_bypass_cache If "true" then the cache is not used.
p_time_budget If "all rows" are fetched (multiple HTTP requests), then the process stops when the time budget is exhausted and an error raises.

Returns

Table 33-42 APEX_PLUGIN_UTIL.MAKE_REST_REQUEST Returns

Parameter Description
p_time_budget Time budget left after request has been made.
p_response Received response of the HTTP invocation.
p_response_parameters Received response headers and cookies, based on REST Data Source meta data.

Example

The following example demonstrates a simplified Plug-In "fetch" procedure doing HTTP requests with APEX_PLUGIN_UTIL.MAKE_REST_REQUEST.

apex_plugin_util.make_rest_request (
    p_plugin     in            apex_plugin.t_plugin,
    p_web_source in            apex_plugin.t_web_source,
    p_params     in            apex_plugin.t_web_source_fetch_params,
    p_result     in out nocopy apex_plugin.t_web_source_fetch_result )
IS
    l_web_source_operation apex_plugin.t_web_source_operation;
    l_time_budget          pls_integer := 60;
    l_page_to_fetch        pls_integer := 1;
    l_continue_fetching    boolean;
BEGIN

    l_web_source_operation := apex_plugin_util.get_web_source_operation(
        p_web_source   => p_web_source,
        p_db_operation => apex_plugin.c_db_operation_fetch_rows,
        p_perform_init => true );

    --
    -- loop to execute HTTP request as long as we receive a response header named "moreRows"
    -- with the value of "true". A time budget of (initially 60) seconds is passed as
    -- IN OUT parameter to MAKE_REST_REQUEST; once that budget is exhausted, an error will
    -- be raised.
    --
    while l_continue_fetching loop
        p_result.responses.extend( 1 );
        l_page_to_fetch := l_page_to_fetch + 1;

        apex_plugin_util.make_rest_request(
            p_web_source_operation => l_web_source_operation,
            p_bypass_cache         => false,
            p_time_budget          => l_time_budget,
            --
            p_response             => p_result.responses( l_page_to_fetch ),
            p_response_parameters  => p_result.out_parameters );

        l_continue_fetching := false;
        for h in 1 .. apex_web_service.g_headers.count loop
            IF apex_web_service.g_headers( h ).name = 'moreRows' and
               apex_web_service.g_headers( h ).value = 'true'
            THEN
                l_continue_fetching := true;
                exit;
            END IF;
        END LOOP;
    END LOOP;
END plugin_fetch;