How to store the response body for non-200 responses in Oracle UTL_HTTP?
2 answers
What I've done in the past is to read the headers and then do a read_line to get the individual lines of the response:
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
source to share