如何在Oracle PL/SQL中传递post请求参数

如何在Oracle PL/SQL中传递post请求参数,oracle,plsql,oracle18c,Oracle,Plsql,Oracle18c,我有一个cURL命令,如下所示: curl --insecure -X POST https://www.example.com -H 'accept-encoding: gzip,deflate' -H 'cache-control: no-cache' -H 'content-type: application/x-www-form-urlencoded' --data "request_type=secure&scope=global&user_id=temp&a

我有一个cURL命令,如下所示:

curl --insecure -X POST https://www.example.com -H 'accept-encoding: gzip,deflate' -H 'cache-control: no-cache' -H 'content-type: application/x-www-form-urlencoded' --data "request_type=secure&scope=global&user_id=temp&password=temppass"
我不确定如何从PL/SQL过程中调用此POST请求

特别是我不知道如何传递数据参数

DECLARE
    http_request    UTL_HTTP.req;
    http_response   UTL_HTTP.resp;
    return_text VARCHAR2(2000);
BEGIN
    http_request := UTL_HTTP.begin_request('https://www.example.com/path/sub_path');

    UTL_HTTP.set_header(http_request, 'accept-encoding', 'gzip,deflate');
    UTL_HTTP.set_header(http_request, 'cache-control', 'no-cache');
    UTL_HTTP.set_header(http_request, 'content-type', 'application/x-www-form-urlencoded');

    UTL_HTTP.set_authentication(http_request, 'temp', 'temppass');

    http_response := UTL_HTTP.get_response(http_request);

    UTL_HTTP.read_text(http_response, return_text);
    dbms_output.put_line (return_text);
END;
/

有谁能帮我做这个吗?提前谢谢

在构建请求的第一个语句中,您声明了HTTP方法

http_request := UTL_HTTP.begin_request('https://www.example.com/path/sub_path','POST');
可以找到一个关于如何发送带有正文的请求的示例

代码示例:

DECLARE
    http_request    UTL_HTTP.req;
    http_response   UTL_HTTP.resp;
    return_text     VARCHAR2 (2000);
BEGIN
    http_request := UTL_HTTP.begin_request ('https://www.example.com/path/sub_path', 'POST');

    UTL_HTTP.set_header (http_request, 'accept-encoding', 'gzip,deflate');
    UTL_HTTP.set_header (http_request, 'cache-control', 'no-cache');
    UTL_HTTP.set_header (http_request, 'content-type', 'application/x-www-form-urlencoded');

    UTL_HTTP.set_authentication (http_request, 'temp', 'temppass');

    UTL_HTTP.write_text (http_request,
                         'request_type=secure&scope=global&user_id=temp&password=temppass');

    http_response := UTL_HTTP.get_response (http_request);

    UTL_HTTP.read_text (http_response, return_text);
    DBMS_OUTPUT.put_line (return_text);
END;
/

在构建请求的第一个语句中,声明HTTP方法

http_request := UTL_HTTP.begin_request('https://www.example.com/path/sub_path','POST');
可以找到一个关于如何发送带有正文的请求的示例

代码示例:

DECLARE
    http_request    UTL_HTTP.req;
    http_response   UTL_HTTP.resp;
    return_text     VARCHAR2 (2000);
BEGIN
    http_request := UTL_HTTP.begin_request ('https://www.example.com/path/sub_path', 'POST');

    UTL_HTTP.set_header (http_request, 'accept-encoding', 'gzip,deflate');
    UTL_HTTP.set_header (http_request, 'cache-control', 'no-cache');
    UTL_HTTP.set_header (http_request, 'content-type', 'application/x-www-form-urlencoded');

    UTL_HTTP.set_authentication (http_request, 'temp', 'temppass');

    UTL_HTTP.write_text (http_request,
                         'request_type=secure&scope=global&user_id=temp&password=temppass');

    http_response := UTL_HTTP.get_response (http_request);

    UTL_HTTP.read_text (http_response, return_text);
    DBMS_OUTPUT.put_line (return_text);
END;
/

谢谢EJ,但是我在哪里或者如何设置--data?中的参数?刚刚用一个例子更新。您需要使用
UTL\u HTTP.WRITE\u TEXT
来填充请求主体。谢谢EJ,但是我在哪里或如何设置--data中的参数?刚刚用一个示例更新。您需要使用
UTL\u HTTP.WRITE\u TEXT
来填充请求主体。