Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to sent a POST request as json in plsql?

user12006543Aug 25 2015 — edited Aug 26 2015

Hi,

I have the following basic code which i use to post a plsql json request.  Each time i execute the SQL,DBMS ouput  '{"err":{"type":"empty_signature","message":"empty signature"}}'. Where is it that i am going wrong?


Thanks!


DECLARE

  req         utl_http.req;

  res         utl_http.resp;

  v_url       VARCHAR2(4000) := 'http://192.168.210.7:8080';

  v_buffer    VARCHAR2(4000);

  v_timestamp VARCHAR2(20);

  v_signature VARCHAR2(50):='ea1fc49de2c72b9dc377aaa79553e7ed';

  v_content   VARCHAR2(4000);

BEGIN

  SELECT to_char(SYSDATE, 'yyyymmddhh24miss') INTO v_timestamp FROM dual;

  v_content   := '{"signature":"' || v_signature || '","timestamp":"' || v_timestamp || '","infos":{"test_no": "test1"}}';

  req         := utl_http.begin_request(v_url, 'POST', 'HTTP/1.1');

  utl_http.set_header(req, 'Content-Type', 'application/json');

  utl_http.set_header(req, 'Content-Length', length(v_content));

  utl_http.write_text(req, v_content);

  dbms_output.put_line(v_content);

  res := utl_http.get_response(req);

  BEGIN

    LOOP

      utl_http.read_line(res, v_buffer);

      dbms_output.put_line(v_buffer);

    END LOOP;

    utl_http.end_response(res);

  EXCEPTION

    WHEN utl_http.end_of_body THEN

      utl_http.end_response(res);

  END;

END;

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 23 2015
Added on Aug 25 2015
2 comments
4,660 views