33.1 BUILD_REQUEST_BODY Procedure

This procedure builds a request body for a REST Data Source DML request. If a request body template is set, then #COLUMN# placeholders will be replaced by the DML context column values. In this case, the request body can be any data format.

If no request body template is set, the function builds a JSON with the following structure:

{
   "{column1-name}": "{column1-value}",
   "{column2-name}": "{column2-value}",
   :
}

Syntax

APEX_PLUGIN_UTIL.BUILD_REQUEST_BODY (
    p_request_format       IN            wwv_flow_plugin_api.t_data_format,
    p_profile_columns      IN            wwv_flow_plugin_api.t_web_source_columns,
    p_values_context       IN            wwv_flow_exec_api.t_context,
    p_build_when_empty     IN            BOOLEAN,
    --
    p_request_body         IN OUT NOCOPY CLOB );

Parameters

Table 33-1 BUILD_REQUEST_BODY Parameters

Parameter Description
p_request_format Request format (JSON or XML).
p_profile_columns Column meta data (names, data types).
p_values_context wwv_flow_exec_api context object containing DML values.
p_build_when_empty If p_request_body is empty, whether to build a new request body.
p_request_body Request body template to perform replacements on.

Returns

Table 33-2 BUILD_REQUEST_BODY Returns

Parameter Description
p_request_body Request body (substitutions replaced or built from scratch).

Example

The following example uses BUILD_REQUEST_BODY within a plug-in DML procedure.

apex_plugin_util.build_request_body (
    p_plugin     in            apex_plugin.t_plugin,
    p_web_source in            apex_plugin.t_web_source,
    p_params     in            apex_plugin.t_web_source_dml_params,
    p_result     in out nocopy apex_plugin.t_web_source_dml_result )
IS
    l_web_source_operation apex_plugin.t_web_source_operation;
    l_request_body         clob;
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_insert,
        p_perform_init => true );

    apex_plugin_util.build_request_body(
        p_request_format       => apex_plugin.c_format_json,
        p_profile_columns      => p_web_source.profile_columns,
        p_values_context       => p_params.insert_values_context,
        p_build_when_empty     => true,
        p_request_body         => l_request_body );

    -- continue with APEX_PLUGIN_UTIL.MAKE_REST_REQUEST

END plugin_dml;