I am trying to call api which return JSON response, my database version is 12.2.0.1.
Below are my codes which return ORA-29268: HTTP client error 400 - Bad Request error but when I try to call same api with SOAPUI then it work perfectly.
DECLARE
l_param_list VARCHAR2(512);
l_http_request UTL_HTTP.req;
l_http_response UTL_HTTP.resp;
l_content VARCHAR2(32767);
l_response_text VARCHAR2(32767);
BEGIN
-- service's input parameters
UTL_HTTP.set_wallet('file:D:\oraclewallet', 'Welcome1');
Utl_Http.set_response_error_check (ENABLE => TRUE );
l_http_request := UTL_HTTP.begin_request ('https://url','GET','HTTP/1.1');;)
utl_http.set_header(l_http_request, 'Authorization', 'Bearer 1234');
utl_http.SET_AUTHENTICATION(l_http_request, 'user', 'pwd');
utl_http.set_header(l_http_request, 'user-agent', 'mozilla/4.0');
utl_http.set_header(l_http_request,'Accept','application/json');
utl_http.set_header(l_http_request, 'content-type', 'application/json');
utl_http.set_header (l_http_request, 'Cache-Control', 'no-cache');
Utl_http.set_header(l_http_request, 'Content-Length', length(l_content));
utl_http.set_header(l_http_request, name => 'Connection', value => 'keep-alive');
utl_http.set_header(l_http_request, name => 'Host', value => 'hostname');
UTL_HTTP.set_header ( l_http_request, 'Transfer-Encoding', 'chunked' );
UTL_HTTP.set_header ( l_http_request, 'Content-Encoding', 'gzip' );
l_http_response := UTL_HTTP.get_response(l_http_request);
BEGIN
LOOP
UTL_HTTP.read_text(l_http_response, l_response_text, 32766);
DBMS_OUTPUT.put_line (l_response_text);
END LOOP;
EXCEPTION
WHEN UTL_HTTP.end_of_body THEN
UTL_HTTP.end_response(l_http_response);
END;
EXCEPTION
WHEN UTL_HTTP.TOO_MANY_REQUESTS THEN
DBMS_OUTPUT.put_line (sqlerrm);
UTL_HTTP.END_RESPONSE(l_http_response);
END;