Skip to content

How to upload Binary (BLOB) Data to REST Endpoint

Binary (BLOB) data which is stored in the database can be sent to a REST endpoint as the message payload via REST Sender. The details of the BLOB table column must be stored in the application message as message body parameters. The request can be sent as a synchronous or asynchronous call.

How to  initiate an asynchronous REST call to send BINARY (BLOB) data
-----------------------------------------------------------------------
PROCEDURE boston_rest_empty_blob_rec IS  
blob_info varchar2(100);  
url_params_ PLSQLAP_DOCUMENT_API.Document;  

BEGIN  
blob_info := 'BLOB_TEMP_TAB,' || 'BLOB_VALUE_,' || 'ROWKEY,' || 'aBcdEFjkL';
url_params_ := PLSQLAP_DOCUMENT_API.New_Document('URL_Parameters');
PLSQLAP_DOCUMENT_API.Add_Attribute(url_params_,'p1', 'ifs/boston');
plsql_rest_sender_API.Call_Rest_EndPoint_Empty_Body2(
        rest_service_ => 'GET_BLOB_DATA',
        url_params_ => url_params_,
        callback_func_ => 'P_L_S_Q_L_Rest_Test_API.REST_callback_Test',
        http_method_ => 'PUT',
        blob_info_ => blob_info);
END boston_rest_empty_blob_rec;
How to  initiate a synchronous REST call to send BINARY (BLOB) data
-----------------------------------------------------------------------
PROCEDURE boston_rest_empty_blob_rec IS  
blob_info varchar2(100);  
url_params_ PLSQLAP_DOCUMENT_API.Document;  
xml_ CLOB;

BEGIN  
blob_info := 'BLOB_TEMP_TAB,' || 'BLOB_VALUE_,' || 'ROWKEY,' || 'aBcdEFjkL';
url_params_ := PLSQLAP_DOCUMENT_API.New_Document('URL_Parameters');
PLSQLAP_DOCUMENT_API.Add_Attribute(url_params_,'p1', 'ifs/boston');
plsql_rest_sender_API.Call_Rest_EP_Empty_Body_Sync2(
           xml_ => xml_, 
           rest_service_ => 'GET_BLOB_DATA',
           url_params_ => url_params_,
           callback_func_ => 'P_L_S_Q_L_Rest_Test_API.REST_callback_Test',
           http_method_ => 'PUT',
           blob_info_ => blob_info);
END boston_rest_empty_blob_rec;

Important points to consider:

  • To send a asynchronous PUT request with Binary Data you have to call the PL/SQL method plsql_rest_sender_API.Call_Rest_EndPoint_Empty_Body(..).
  • To send a synchronous PUT request with Binary Data you have to call the PL/SQL method plsql_rest_sender_API.Call_Rest_EP_Empty_Body_Sync(..).
  • Note that we don't set any payload as a Record Structure/XML from PL/SQL side when sending Binary Data to a REST endpoint.