I am new to PL/JSON and have done a lot of searching and still can't find a solution.
I am attempting to create a JSON request and post the data to a service. However, I can't seem to successfully use the to_clob procedure.
Any help is greatly appreciated.
Currently using the following code:
function push_json_packet(p_request IN json) return BOOLEAN IS t_http_req utl_http.req; t_http_resp utl_http.resp; t_request_body CLOB; t_request_json json; t_respond varchar2(30000);
begin t_request_json := p_request;
-- This line keeps returning "wong number or types: to_clob" t_request_json.to_clob(t_request_json, t_request_body);
t_http_req:= utl_http.begin_request( 'https://approval.com/receive', 'POST' , 'HTTP/1.1');
utl_http.set_authentication(t_http_req,'user','pwd');
utl_http.set_header(t_http_req, 'Content-Type', 'application/jsonrequest;charset=UTF-8');
utl_http.set_transfer_timeout(60);
utl_http.set_header(t_http_req, 'Transfer-Encoding', 'chunked');
utl_http.write_raw(t_http_req, t_request_body);
t_http_resp:= utl_http.get_response(t_http_req);
utl_http.read_text(t_http_resp, t_respond);
utl_http.end_response(t_http_resp);
return TRUE;
end push_json_packet;
This works for me:
DECLARE j json := json('{"key":"value"}'); c CLOB; BEGIN j.print; DBMS_LOB.createtemporary(c, TRUE, DBMS_LOB.call); j.to_clob(c, FALSE, dbms_lob.lobmaxsize); dbms_output.put_line('-----' || CHR(10) || c); END;
-- Herb Swift™ (sæ•só•nus ra•pí•dus™)
"Keep your stick on the ice and keep reaching for the stars." -- Red Green, d. April 7, 2006 and Casey Kasem, d. June 15, 2014
On Fri, Sep 12, 2014 at 4:04 PM, Tim Metzger tmetzger13@users.sf.net wrote:
I am new to PL/JSON and have done a lot of searching and still can't find a solution. I am attempting to create a JSON request and post the data to a service. However, I can't seem to successfully use the to_clob procedure. Any help is greatly appreciated. Currently using the following code: function push_json_packet(p_request IN json) return BOOLEAN IS t_http_req utl_http.req; t_http_resp utl_http.resp; t_request_body CLOB; t_request_json json; t_respond varchar2(30000); begin t_request_json := p_request; -- This line keeps returning "wong number or types: to_clob" t_request_json.to_clob(t_request_json, t_request_body); t_http_req:= utl_http.begin_request( 'https://approval.com/receive', 'POST' , 'HTTP/1.1'); utl_http.set_authentication(t_http_req,'user','pwd'); utl_http.set_header(t_http_req, 'Content-Type', 'application/jsonrequest;charset=UTF-8'); utl_http.set_transfer_timeout(60); utl_http.set_header(t_http_req, 'Transfer-Encoding', 'chunked'); utl_http.write_raw(t_http_req, t_request_body); t_http_resp:= utl_http.get_response(t_http_req); utl_http.read_text(t_http_resp, t_respond); utl_http.end_response(t_http_resp); return TRUE; end push_json_packet; Create JSON request and POST / UTL_HTTP https://sourceforge.net/p/pljson/discussion/935365/thread/d146c17f/?limit=25#653b Sent from sourceforge.net because you indicated interest in https://sourceforge.net/p/pljson/discussion/935365/ To unsubscribe from further messages, please visit https://sourceforge.net/auth/subscriptions/
Create JSON request and POST / UTL_HTTP https://sourceforge.net/p/pljson/discussion/935365/thread/d146c17f/?limit=25#653b
Sent from sourceforge.net because you indicated interest in https://sourceforge.net/p/pljson/discussion/935365/
To unsubscribe from further messages, please visit https://sourceforge.net/auth/subscriptions/
That did the trick. Thanks for your help.
Tim
Log in to post a comment.
I am new to PL/JSON and have done a lot of searching and still can't find a solution.
I am attempting to create a JSON request and post the data to a service. However, I can't seem to successfully use the to_clob procedure.
Any help is greatly appreciated.
Currently using the following code:
function push_json_packet(p_request IN json)
return BOOLEAN
IS
t_http_req utl_http.req;
t_http_resp utl_http.resp;
t_request_body CLOB;
t_request_json json;
t_respond varchar2(30000);
begin
t_request_json := p_request;
-- This line keeps returning "wong number or types: to_clob"
t_request_json.to_clob(t_request_json, t_request_body);
t_http_req:= utl_http.begin_request( 'https://approval.com/receive', 'POST' , 'HTTP/1.1');
utl_http.set_authentication(t_http_req,'user','pwd');
utl_http.set_header(t_http_req, 'Content-Type', 'application/jsonrequest;charset=UTF-8');
utl_http.set_transfer_timeout(60);
utl_http.set_header(t_http_req, 'Transfer-Encoding', 'chunked');
utl_http.write_raw(t_http_req, t_request_body);
t_http_resp:= utl_http.get_response(t_http_req);
utl_http.read_text(t_http_resp, t_respond);
utl_http.end_response(t_http_resp);
return TRUE;
end push_json_packet;
This works for me:
DECLARE
j json := json('{"key":"value"}');
c CLOB;
BEGIN
j.print;
DBMS_LOB.createtemporary(c, TRUE, DBMS_LOB.call);
j.to_clob(c, FALSE, dbms_lob.lobmaxsize);
dbms_output.put_line('-----' || CHR(10) || c);
END;
--
Herb Swift™ (sæ•só•nus ra•pí•dus™)
"Keep your stick on the ice and keep reaching for the stars."
-- Red Green, d. April 7, 2006 and Casey Kasem, d. June 15, 2014
On Fri, Sep 12, 2014 at 4:04 PM, Tim Metzger tmetzger13@users.sf.net
wrote:
That did the trick. Thanks for your help.
Tim