【问题标题】:Calling Mailgun Rest API from Oracle APEX从 Oracle APEX 调用 Mailgun Rest API
【发布时间】:2020-11-08 09:11:43
【问题描述】:

我使用 Oracle Apex 19,需要创建一个使用 Mailgun REST API 发送邮件的程序。

如果我在控制台上编写下一个 curl 代码,它可以正常工作:

curl --location --request POST 'https://api.mailgun.net/v3/example.com.ar/messages' \
--header 'Authorization: Basic <<my-secrect-api-code>>' \
--form 'from=postmaster@example.com.ar' \
--form 'to=test@gmail.com' \
--form 'subject=Test' \
--form 'template=mytemplatename'

在邮递员中也能正常工作:

怎么说呢,我需要把这段代码翻译成 APEX PL/SQL,我试过了

    declare
      -- Local variables here
      i      integer;
      l_resp clob;
      g_url  varchar2(300) := 'https://api.mailgun.net/v3/example.com.ar/messages';
    
    begin
      -- Test statements here
    
      apex_web_service.g_request_headers(1).name := 'Authorization';
      apex_web_service.g_request_headers(1).Value := 'Basic my-secret-code';
    
    
      l_resp := apex_web_service.make_rest_request(p_url         => g_url,
                                                   p_http_method => 'POST',
                                                   p_parm_name  => apex_util.string_to_table('from:to:subject:template',':'),
                                                   p_parm_value => apex_util.string_to_table('postmaster@example.com.ar:test@gmail.com:helo:mytemplate',':'),
                                                   p_wallet_path =>'file:/backup/wallet',
                                                   p_wallet_pwd  => null);
    
    dbms_output.put_line(L_resp);

end;

当调用 pl/sql 过程时,我总是得到错误:

{
  "message": "'from' parameter is missing"
}

听起来好像没有发送FORM参数,但我不知道如何使用APEX_WEB_SERVICE发出这个请求。

你能帮帮我吗?

【问题讨论】:

    标签: oracle-apex mailgun oracle-apex-5.1


    【解决方案1】:

    添加参数“Content-Type”我已经解决了问题:

    apex_web_service.g_request_headers(2).name := 'Content-Type';
    apex_web_service.g_request_headers(2).value := 'application/x-www-form-urlencoded';

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多