I find that if I call UTL_HTTP.GET_RESPONSE
and get an error response (500 in this case), when I call UTL_HTTP.READ_TEXT
it fails with ORA-29261: bad argument
. How can I see the response body when there is an error?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
What I've done in the past is to read through the headers and then do a read_line to get the individual response lines:
v_resp := utl_http.get_response (v_req);
v_status := v_resp.status_code;
FOR i IN 1..UTL_HTTP.GET_HEADER_COUNT(v_resp) LOOP
utl_http.get_header(v_resp, i, v_name, v_value);
dbms_output.put_line(v_name || ': ' || v_value);
END LOOP;
BEGIN
utl_http.read_line(v_resp, v_value, TRUE);
v_response := v_value;
dbms_output.put_line(v_value);
EXCEPTION
WHEN OTHERS THEN
NULL; -- handle exception here
END;
回答2:
The solution ended up being to call
UTL_HTTP.set_response_error_check(false);
before making the request.