PL/SQL calls REST webservice
Function f_rest_call( stringjson )
req utl_http.req;
res utl_http.resp;
url varchar2(2000) := 'REST url';
buffer varchar2(1000);
content varchar2(4000) := stringjson ;
begin
req := utl_http.begin_request(url, 'POST','
HTTP/1.1');
utl_http.set_header(req, 'user-agent',
'mozilla/4.0');
utl_http.set_header(req, 'content-type',
'application/json');
utl_http.set_header(req, 'Content-Length',
length(content));
----//SYS.utl_http.write_raw(req, contentgetStringVal());
utl_http.write_text(req, content);
res := utl_http.get_response(req);
begin
loop
utl_http.read_line(res, buffer);
end loop;
utl_http.end_response(res);
exception
when utl_http.end_of_body
then
utl_http.end_response(res);
end;
end
No comments:
Post a Comment