I am trying to make a post call with client credentials for an api through plsql code.
Everytime I make the call, I get tns timeout.
Attaching the code for reference and also the output.
test_code.txt (1.62 KB)
code_error.PNG (19.84 KB)Any suggestion on how I can tweak the code. PLSQL code on successful run should return back the access token.
Code Snippet:
SET DEFINE OFF;
SET SERVEROUTPUT ON;
DECLARE
http_req utl_http.req;
l_response utl_http.resp;
l_value CLOB;
l_raw VARCHAR2(32767);
l_clob CLOB;
l_count NUMBER;
req_body VARCHAR2(2000);
v_client_id VARCHAR2(500) := '0******************************7';
v_client_secret VARCHAR2(500) := 'l*************************************0';
BEGIN
req_body := 'grant_type=client_credentials&client_id=' || v_client_id || '&client_secret=' || v_client_secret;
dbms_output.put_line('Setting wallet');
utl_http.set_wallet('file:/u01/app/oracle/product/12.1.0.2/dbhome_1/owm/wallets', 'xa2_Df43xP11');
dbms_output.put_line('Setting wallet Done');
http_req := utl_http.begin_request( 'https://api-test.blackrock.com/oauth/token'
, 'POST'
, 'HTTP/1.1');
UTL_HTTP.set_header ( http_req
, 'Content-Type'
, 'application/x-www-form-urlencoded' );
UTL_HTTP.set_header ( http_req
, 'Content-Length'
, LENGTH (req_body));
UTL_HTTP.write_text ( http_req
, req_body);
dbms_output.put_line('Initiate Request');
l_response := utl_http.get_response(http_req);
dbms_output.put_line(req_body);
utl_http.read_text(l_response, l_raw);
UTL_HTTP.end_response (l_response);
UTL_HTTP.end_request (http_req);
dbms_output.put_line('value: '||l_raw);
apex_json.parse(l_raw);
dbms_output.put_line(apex_json.get_varchar2(p_path=>'access_token'));
EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line(SQLERRM);
END;