I am trying to Send Emails using SparkPost Email REST API but am running into the following error:
[
ERR-ORA-29273: HTTP request failed
ORA-06512: at "SYS.UTL_HTTP", line 1130
ORA-29259: end-of-input reached
]
I can execute the REST API without issue from Postman.
I have imported SparkPosts SSL cert into my oracle wallet, and I believe I have set my headers correctly, below is the code that I am using.
*******************************************
declare
lv_sparkpost_url varchar2(1024);
lv_sparkpost_key varchar2(256);
lv_return CLOB;
lv_request CLOB;
ldap_wallet VARCHAR2(256) := 'file:/u01/app/oracle/admin/PROD/ldapauth';
ldap_wpass VARCHAR2(256) := '<walletpass>';
v_code varchar2(1024);
v_errm varchar2(1024);
BEGIN
lv_sparkpost_url := 'https://api.sparkpost.com/api/v1/transmissions';
lv_sparkpost_key := '<sparkpostkey>';
lv_request := '{"content": {"from": "test@test.domain.com, "subject": "A Great Email", "text": "With great things to say."}, "recipients": [{"address": "<my-email-addr>"}]}';
BEGIN
apex_web_service.g_request_headers.delete;
APEX_WEB_SERVICE.G_REQUEST_HEADERS(1).NAME := 'Content-Type';
apex_web_service.g_request_headers(1).Value := 'application/json';
APEX_WEB_SERVICE.G_REQUEST_HEADERS(2).NAME := 'Authorization';
--apex_web_service.g_request_headers(1).Value := 'Basic '|| lv_sparkpost_key;
apex_web_service.g_request_headers(2).Value := lv_sparkpost_key;
lv_return := APEX_WEB_SERVICE.MAKE_REST_REQUEST(
p_url => lv_sparkpost_url,
p_http_method => 'POST',
--p_username => null,
--p_password => null,
--p_proxy_override => null,
p_transfer_timeout => 180,
--p_parm_name => apex_util.string_to_table(p_string => , p_separator => ';'),
--p_parm_value => apex_util.string_to_table(p_string => , p_separator => ';'),
p_body => lv_request,
p_wallet_path => ldap_wallet,
p_wallet_pwd => ldap_wpass
);
dbms_output.put_line('lv_return: '|| lv_return);
EXCEPTION
WHEN OTHERS THEN
v_code := SQLCODE;
v_errm := SUBSTR(SQLERRM, 1, 255);
DBMS_OUTPUT.PUT_LINE('ERR-' || v_errm);
END;
COMMIT;
END;
*******************************************
Any help would be appreciated, I have used simular code before to execute Twilio SMS API, execute Google maps API, etc, but this is the first time I have come across this error before.
Thanks
Jason