Dear Oracle community,
I keep getting a error “Missing form parameter: grant_type” every time I call my procedure and I cant figure out what I am doing wrong. Database version is 12c (12.2.0.1.0). The rest service is using OAuth 2 authorization and call from postman is working:
declare
req utl_http.req;
res utl_http.resp;
url varchar2 (500);
granttype varchar2 (100) := 'client_credentials'; -- Specify your grant type
clientid varchar2 (100) := 'your_client_id';
secret varchar2 (100) := 'your_client_secret';
params varchar2 (500);
responsebody clob;
begin
url := 'https://example.com/token_endpoint'; -- Replace with your endpoint
params := 'grant_type=' || utl_url.escape (granttype) || '&client_id=' || utl_url.escape (clientid) || '&client_secret=' || utl_url.escape (secret);
req := utl_http.begin_request (url, 'POST', utl_http.http_version_1_1);
utl_http.set_header (req, 'Content-Type', 'application/x-www-form-urlencoded');
utl_http.set_body_charset (req, 'UTF-8');
utl_http.write_text (req, params);
res := utl_http.get_response (req);
utl_http.read_text (res, responsebody);
dbms_output.put_line (responsebody);
utl_http.end_response (res);
exception
when utl_http.end_of_body
then
utl_http.end_response (res);
end;
/