Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Problems getting UTL_HTTP example from Oracle doc to work (client error 400 -- bad request)
All,
Below is the description of my problem. I've taken sample code directly out of the Oracle documentation (http://www.di.unipi.it/~ghelli/bdl/B10501_01/appdev.920/a96612/u_http.htm#1013135) and it doesn't work. I've slightly modified the example code to point at www.yahoo.com and commented out the proxy statement (because in IE I don't have a proxy set and my network doesn't have a proxy server). I get the error indicated at the bottom of this post.
My version information
Example from Oracle documentation: Using UTL_HTTP
SET serveroutput ON SIZE 40000
DECLARE
req utl_http.req;
resp utl_http.resp;
value VARCHAR2(1024);
BEGIN
utl_http.set_proxy('proxy.my-company.com', 'corp.my-company.com');
req := utl_http.begin_request('http://www-hr.corp.my-company.com');
utl_http.set_header(req, 'User-Agent', 'Mozilla/4.0');
resp := utl_http.get_response(req);
LOOP
utl_http.read_line(resp, value, TRUE);
dbms_output.put_line(value);
END LOOP;
utl_http.end_response(resp);
EXCEPTION
WHEN utl_http.end_of_body THEN
utl_http.end_response(resp);
END;
My slightly modified version of the example code (changed URL and
commented out proxy)
SET serveroutput ON SIZE 40000
DECLARE
req utl_http.req;
resp utl_http.resp;
value VARCHAR2(1024);
BEGIN
req := utl_http.begin_request('http://www.yahoo.com');
utl_http.set_header(req, 'User-Agent', 'Mozilla/4.0');
resp := utl_http.get_response(req);
LOOP
utl_http.read_line(resp, value, TRUE);
dbms_output.put_line(value);
END LOOP;
utl_http.end_response(resp);
EXCEPTION
WHEN utl_http.end_of_body THEN
utl_http.end_response(resp);
END;
Error response when this code is executed in SQL Plus
SQL> SET serveroutput ON SIZE 40000 SQL> SQL> DECLARE
13 utl_http.read_line(resp, value, TRUE); 14 dbms_output.put_line(value);
ORA-29268: HTTP client error 400 - Bad Request ORA-06512: at "SYS.UTL_HTTP", line 1220 ORA-06512: at line 11
Thanks in advance for your help!
Rob Received on Thu Nov 18 2004 - 11:51:55 CST