utl_http.HTTP_CONTINUE example

938 Views Asked by At

I would like to use "utl_http.HTTP_CONTINUE" on my pl sql code. But I could not find any example how to use this. Can anyone help me about how to use "utl_http.HTTP_CONTINUE" during calling rest api from pl sql side?

1

There are 1 best solutions below

0
TuringMachine On

In the oracle Documentation:

HTTP_CONTINUE

DECLARE
 data  VARCHAR2(1024) := '...';
 req   utl_http.req;
 resp  utl_http.resp;
BEGIN
   
 req := utl_http.begin_request('http://www.acme.com/receiver', 'POST');
 utl_http.set_header(req, 'Content-Length', length(data));
 -- Ask HTTP server to return "100 Continue" response
 utl_http.set_header(req, 'Expect', '100-continue');
 resp := utl_http.get_response(req, TRUE);
   
 -- Check for and dispose "100 Continue" response
 IF (resp.status_code <> 100) THEN
   utl_http.end_response(resp);
   raise_application_error(20000, 'Request rejected');
 END IF;
 utl_http.end_response(resp);
   
 -- Now, send the request body
 utl_http.write_text(req, data);
 
 -- Get the regular response
 resp := utl_http.get_response(req);
 utl_http.read_text(resp, data);
   
 utl_http.end_response(resp);
   
END;