Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Problems getting UTL_HTTP example from Oracle doc to work (client error 400 -- bad request)

Problems getting UTL_HTTP example from Oracle doc to work (client error 400 -- bad request)

From: Robert Holcomb <rcholcomb1999-post_at_yahoo.com>
Date: 18 Nov 2004 09:51:55 -0800
Message-ID: <e0f934c3.0411180951.6341b14a@posting.google.com>


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



Oracle9i Release 9.2.0.1.0 - Production
JServer Release 9.2.0.1.0 - Production

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

  2 req utl_http.req;
  3 resp utl_http.resp;
  4 value VARCHAR2(1024);
  5 BEGIN
  6
  7 -- utl_http.set_proxy('proxy.my-company.com', 'corp.my-company.com');
  8
  9 req := utl_http.begin_request('http://www.yahoo.com');  10 utl_http.set_header(req, 'User-Agent', 'Mozilla/4.0');  11 resp := utl_http.get_response(req);  12 LOOP
 13      utl_http.read_line(resp, value, TRUE);
 14      dbms_output.put_line(value);

 15 END LOOP;
 16 utl_http.end_response(resp);
 17 EXCEPTION
 18 WHEN utl_http.end_of_body THEN
 19 utl_http.end_response(resp);
 20 END;
 21 /
DECLARE
*
ERROR at line 1:
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

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US