I've been trying to integrate oracle SQL with an API that sends a SMS with a token, it has been simple to use it in the web, but when i try to use the use it on the oracle SQL it doesn't work.
I’m not very familiar with using REST on PL-SQL so I’m
not so sure what is missing, I’ve already requested the DBA to create a wallet
but Iven when using it, does not work.
my code
DECLARE
l_vc_url VARCHAR2(100):='https://sms.comtele.com.br/api/v2/tokenmanager';
l_rc_key UTL_HTTP.REQUEST_CONTEXT_KEY;
l_http_req UTL_HTTP.REQ;
l_http_resp UTL_HTTP.RESP;
l_vc_html VARCHAR2(1024);
BEGIN
l_rc_key := UTL_HTTP.CREATE_REQUEST_CONTEXT( wallet_path => 'file:/u01/app/oracle/product/12.1.0.2/dbhome_1/wallet_sms'
, wallet_password => 'MyPasswd',
enable_cookies => TRUE
, max_cookies => 100
, max_cookies_per_site => 10);
dbms_output.put_line('Request Context Key: '||l_rc_key);
l_http_req := UTL_HTTP.BEGIN_REQUEST(url => l_vc_url
, method => 'POST'
, request_context => l_rc_key);
UTL_HTTP.SET_HEADER(l_http_req, 'content-type', 'application/json');
UTL_HTTP.SET_HEADER(l_http_req, 'auth-key', 'my-key');
l_http_resp := UTL_HTTP.GET_RESPONSE(l_http_req);
BEGIN
LOOP
UTL_HTTP.READ_LINE(l_http_resp, l_vc_html,true);
dbms\_output.put\_line(l\_vc\_html);
END LOOP;
EXCEPTION
WHEN UTL_HTTP.END_OF_BODY THEN
UTL_HTTP.END_RESPONSE(l_http_resp);
END;
UTL_HTTP.DESTROY_REQUEST_CONTEXT(l_rc_key);
END;
documentation:
Comtele API Rest Docs (0 Bytes)