Hello all,
I am trying to use oracle apex 22.1 to send push notifications.
I tried pl/sql using apex_web_service but it fails with error 400 BAD REQUEST
Here is the code:
"declare lc_result clob;
err_rest exception;
begin
apex_web_service.g_request_headers(1).name := ‘webpushrKey’;
apex_web_service.g_request_headers(1).value := ‘4ksdl;kfjdl;skgdfl;kgdf’;
apex_web_service.g_request_headers(2).name := ‘Content-Type’;
apex_web_service.g_request_headers(2).value := ‘application/json’;
apex_web_service.g_request_headers(3).name := ‘webpushrAuthToken’;
apex_web_service.g_request_headers(3).value := ‘xzxzxz’;
lc_result := apex_web_service.make_rest_request(
p_url => ‘webpusher endpoinr’ ,
p_http_method => ‘post’,
p_body =>’’,
p_parm_name => apex_util.string_to_table(‘data’),
p_parm_value => apex_util.string_to_table(’{“title”:“notification_title”,“message”:“notification message”,“target_url”:“MY URL”,“action_buttons”:[{“title”:“Demo”, “url”:“MY URL”},{“title”:“Pricing”, “url”:“MY URL”}]}’)
:P78_NEW :=lc_result;
exception
when others then raise_application_error(-20001,sqlerrm);
end;"
I tried REST Data source but it fails with invalid json format…
I even tried javascript using fetch request but I always have this error:
“Access to fetch at ‘webpusher endpoint’ from origin ‘oracle url’ has been blocked by CORS policy: Response to preflight request doesn’t pass access control check: It does not have HTTP ok status.”
I am wondering if there is a way to do this task using Oracle Apexs?