Skip to Main Content

APEX post restful service inserts null value

guyenkoMay 28 2014 — edited Aug 10 2014

Oracle APEX 4.2.5

Oracle Rest Data Service 2.0.7

Apache Tomcat 7

Oracle database 11.2.0.4

Oracle APEX PUT web service inserts null value into column. This is either a bug or the documentation does not properly cover how to correctly set PUT restful services. 

GET web services works fine. 

I have granted the role of apex_rest_public_user to both apex_public_user and the schema owner. 

The payload is a small xml document, but even a text document will yield the same result. 

I am using the Oracle REST Data Service 2.0.5

Web service code: 

RESTful Service Module: software_details/

URI Template: xml_parser

Method: POST

Source Type: PL/SQL

MIME: Types Allowed: application/xml

Requires Secure Access: NO

Source :

begin

insert into clob_test (x)

values (blob_to_clob(:body)); ## according to some online post,  :body is where APEX places any data being transferred through a web service. I have yet to find any official  ##documentation on it. 

commit:

end;

##Blob_to_clob function code

CREATE OR REPLACE FUNCTION blob_to_clob (blob_in IN BLOB)

RETURN CLOB

AS

      v_clob    CLOB;

      v_varchar VARCHAR2(32767);

      v_start      PLS_INTEGER := 1;

      v_buffer  PLS_INTEGER := 32767;

BEGIN

      DBMS_LOB.CREATETEMPORARY(v_clob, TRUE);

      FOR i IN 1..CEIL(DBMS_LOB.GETLENGTH(blob_in) / v_buffer)

      LOOP

         v_varchar := UTL_RAW.CAST_TO_VARCHAR2(DBMS_LOB.SUBSTR(blob_in, v_buffer, v_start));

            DBMS_LOB.WRITEAPPEND(v_clob, LENGTH(v_varchar), v_varchar);

           v_start := v_start + v_buffer;

      END LOOP;

    RETURN v_clob;

END blob_to_clob;

/

#Table code 

create table clob_test(

x clob));

Thank you,

Comments
Post Details
Added on May 28 2014
3 comments
2,092 views