Quantcast
Channel: Active questions tagged rest - Stack Overflow
Viewing all articles
Browse latest Browse all 3619

Invoke a REST service from PL/SQL

$
0
0

I am trying to make a HTTP Request from PL/Sql. I need to use access token for authentication rather than username and password. Please suggest the standard API or code to use to pass the access token.

Code:

    DECLARE        obj           json;        val_          json_value;        el_val      BOOLEAN;        req            utl_http.req;        res            utl_http.resp;        url             VARCHAR2(4000) := 'http://acdl-act-         dev.azurewebsites.net/apiconn/push';        name        VARCHAR2(4000);    buffer        CLOB;    l_chunk     VARCHAR2(32000);    content      CLOB := '{ "User_Name":"John","City":"Delhi", "Operation":"I"';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/x-www-form-urlencoded' );    utl_http.set_header( req,'Content-Length', length(content));-- utl_http.set_authentication(r => req, username    => p_user_name, password    => p_pwd,scheme      => 'Basic',for_proxy   => false);-- Need to use access token for authentication ex: 'adghjcjhdnmfbhjd367dsbasfkjhkdfsf38789734bcff'        utl_http.write_text(req, content);        res := utl_http.get_response(req);      -- process the response from the HTTPS call        BEGIN            LOOP                utl_http.read_line(res, buffer);            END LOOP;            utl_http.end_response(res);        EXCEPTION            WHEN utl_http.end_of_body THEN                utl_http.end_response(res);        END;END ws_call_code;/

Viewing all articles
Browse latest Browse all 3619

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>