sql - 如何从 SQL 触发 REST API
问题描述
我想从 SQL 中触发 REST API(POST CALL)。我创建了以下程序来做同样的事情。但面临有关 utl_http 包因访问控制列表 (ACL) 拒绝而被拒绝的问题
i have followed the steps mentioned in this article -
http://dbtricks.com/?p=159
but still getting the below error -
EXEC schedule_email
Error report -
ORA-29273: HTTP request failed
ORA-06512: at "SYS.UTL_HTTP", line 1130
ORA-24247: network access denied by access control list (ACL)
ORA-06512: at "P_STGATGCOMM.SCHEDULE_EMAIL", line 9
ORA-06512: at line 1
29273. 00000 - "HTTP request failed"
*Cause: The UTL_HTTP package failed to execute the HTTP request.
*Action: Use get_detailed_sqlerrm to check the detailed error message.
Fix the error and retry the HTTP request.
below is my procedure
create or replace
procedure schedule_email AS PRAGMA AUTONOMOUS_TRANSACTION;
req utl_http.req;
res utl_http.resp;
url varchar2(4000) := 'http://localhost:8080/api/scheduleEmail';
name varchar2(4000);
buffer varchar2(4000);
content varchar2(4000) := '{"email":"sanjeev.rai@yopmail.com", "subject":"This isa subject", "body":"This isa body", "dateTime":"2019-09-03T15:20:00","timeZone":"Asia/Kolkata"}';
begin
req := utl_http.begin_request(url, 'POST',' HTTP/1.1');
-- utl_http.set_header(req, 'user-agent', 'mozilla/4.0');
utl_http.set_header(req, 'content-type', 'application/json');
utl_http.set_header(req, 'Content-Length', length(content));
utl_http.write_text(req, content);
res := utl_http.get_response(req);
-- process the response from the HTTP call
begin
loop
utl_http.read_line(res, buffer);
dbms_output.put_line(buffer);
end loop;
utl_http.end_response(res);
exception
when utl_http.end_of_body
then
utl_http.end_response(res);
end;
end schedule_email;
解决方案
推荐阅读
- powershell - PowerShell 可以创建没有名称的快捷方式
- visual-studio - ##[警告]未找到 Visual Studio 版本“14.0”。回退到版本 '15.0'
- jquery - jQuery 在 mouseenter 上具有不同类的相同功能
- electron - 如何在 electronJS 中为不同的文件扩展类型设置不同的图标?
- reactjs - 如何为常见的 Reactstrap 组件添加动画?
- spring - Spring Data findAllById 无法正常工作
- javascript - Amcharts 没有为所有图表显示一个气球
- javascript - Java 脚本文件阅读器 我怎样才能使它成为一个多文件阅读器?
- spring - 服务器发送事件错误:Angular5 + Spring App 中的 406(不可接受)
- mysql - 缺少数据库连接 cakephp