Friday, May 4, 2018

PL/SQL calls REST webservice


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));
  utl_http.set_header(req, 'Authorization', 'Basic d124553rpwYXNzd29yZA=='); --It Uses Basic Authorization 
  ----//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

AWS how to delete VPC when it has error with Network interface , Gateway decencies

   how to delete VPC when it has error with Network interface , Gateway decencies  in AWS 1. Check if it is running on EC2 instance then Sto...