Hi,
Could you help-me please. I am tryed to execute a simple command and does not work.
SELECT utl_http.request('
http://www.oracle.com/' ) FROM dual
*
ERROR at line 1:
ORA-29273: HTTP request failed
ORA-12535: TNS:operation timed out
ORA-06512: at "SYS.UTL_HTTP", line 1491
ORA-06512: at line 1
I tryed in cloud anvironment and dos not work too. I am conected as Admin;
ORA-01031: insufficient privileges ORA-06512: at "SYS.UTL_HTTP", line 1810 ORA-06512: at "SYS.UTL_HTTP", line 136 ORA-06512: at "SYS.UTL_HTTP", line 1745 ORA-06512: at line 1
I want to do a interface using HTTP to send data to a IoT plataform.
when I comment the line where is the comand UTL_HTTP.begin_request don't occur error and show I have access to the package UTL_HTTP...
DECLARE
l_url VARCHAR2(50) := '
http://api.losant.com'; l_http_request UTL_HTTP.req;
l_http_response UTL_HTTP.resp;
BEGIN
-- Make a HTTP request and get the response.
--l_http_request := UTL_HTTP.begin_request(l_url, 'GET', 'HTTP/1.1'); <<----------------- Why don't I have access?
--l_http_response := UTL_HTTP.get_response(l_http_request);
UTL_HTTP.end_response(l_http_response);
END;
You don't query a UTL_HTTP request from dual.
Here's a simple fragment as an example of getting arbitrary length data from a http end point
set serverout on
declare
l_url varchar2(100) := '[your url]';
l_req utl_http.req;
l_resp utl_http.resp;
l_content clob;
l_buffer varchar2(32767);
begin
dbms_lob.createtemporary(l_content, false);
l_req := utl_http.begin_request(l_url);
l_resp := utl_http.get_response(l_req);
begin
loop
utl_http.read_text(l_resp, l_buffer, 32000);
dbms_lob.writeappend (l_content, length(l_buffer), l_buffer);
end loop;
exception
when utl_http.end_of_body then
utl_http.end_response(l_resp);
end;
dbms_output.put_line('Size='||length(l_content));
dbms_lob.freetemporary(l_content);
end;
/
If you're looking at sending data to an IoT platform, they might be expecting you to make a REST call. If that's the case I'd suggest APEX_WEB_SERVICE
https://docs.oracle.com/cd/E59726_01/doc.50/e39149/apex_web_service.htm#AEAPI537 which takes care of a lot of the heavy lifting for you.
Similarly, if you are using https not http, then check out Tim's article on how to get that up and running
https://oracle-base.com/articles/misc/utl_http-and-ssl