I'm calling to an API from a Procedure.
This API is sending the response with GZIP compression:
l_http_request := utl_http.begin_request('http://api.test.com/v1/testService?date=2024-01-03', 'GET', 'HTTP/1.1');
utl_http.set_header(l_http_request, 'Accept-Encoding', 'gzip,deflate');
utl_http.set_header(l_http_request, 'Connection', 'Keep-Alive');
l_http_response := utl_http.get_response(l_http_request);
If I get the response with “read_text”
utl_http.read_text(l_http_response, l_response_text);
I get an unreadable response:
]Gr®ç~Æ&÷Ë …….
If I use “utl_compress.lz_uncompress” to uncompress the response:
-- Copy the response into the BLOB.
begin
loop
utl_http.read_raw(l_http_response, l_raw, 32766);
dbms_lob.writeappend (l_blob, utl_raw.length(l_raw), l_raw);
end loop;
exception
when utl_http.end_of_body then
utl_http.end_response(l_http_response);
end;
l_blob := utl_compress.lz_uncompress(l_blob);
If I print this blob, I only get numbers:
dbms_output.put_line( utl_raw.cast_to_raw(dbms_lob.substr(l_blob,200,1)) );
-→ 37423041323032303232363436313734363132323341323035423 ….
Is utl_compress the best way to do this?
Regards,
Josep