1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
| procedure GetToken( p_url IN CHAR, p_username IN CHAR DEFAULT NULL, p_password IN CHAR DEFAULT NULL) is
http_request UTL_HTTP.req;
http_response UTL_HTTP.resp;
http_text VARCHAR2(32767);
content varchar2(4000):='{ "login":"'||p_username||'","password":"'||p_password||'"}';
BEGIN
-- Make a HTTP request and get the response.
http_request := UTL_HTTP.begin_request(p_url, 'POST','HTTP/1.1');
utl_http.set_header(http_request, 'user-agent', 'chrome/87.0');
utl_http.set_header(http_request, 'content-type', 'application/json');
utl_http.set_header(http_request, 'Content-Length', length(content));
utl_http.write_text(http_request, content);
http_response := utl_http.get_response(http_request);
-- Loop through the response.
BEGIN
LOOP
UTL_HTTP.read_text(http_response, http_text, 32766);
DBMS_OUTPUT.put_line (http_text);
END LOOP;
EXCEPTION
WHEN UTL_HTTP.end_of_body THEN
UTL_HTTP.end_response(http_response);
END;
EXCEPTION
WHEN OTHERS THEN
UTL_HTTP.end_response(http_response);
RAISE;
END ; |
Partager