Create issue from ORACLE procedure into GitLab

Hi,

Do you know if it is possible to create a ORACLE procedure to insert an issue into GitLab ?

I was thinking to do something like :

declare
l_json_clob clob;
l_json_response varchar2(15000);
l_wallet_loc_nopass varchar2(50) := ‘file:c:\oracle_wallet\WALLETS’;
l_gitlab_user varchar2(50) := ‘eric.sacramento’;
l_gitlab_pw varchar2(50) := ‘lkmasdpoadpaid’;
l_gitlab_api_create_issue varchar2(50) := ‘https://gitlab.com/api/v4/projects/4/issues/’;

begin
apex_web_service.g_request_headers(1).name := ‘Content-Type’;
apex_web_service.g_request_headers(1).Value := ‘application/json’;

l_json_clob := ‘{
“project_id” : 4,
“id” : 84,
“created_at” : “2019-02-07T12:44:33.959Z”,
“iid” : 14,
“title” : “Create Issue From API”,
“state” : “opened”,
“assignees” : ,
“assignee” : null,
“labels” : [
“bug”
]}’;
l_json_response := apex_web_service.make_rest_request
( p_url => l_gitlab_api_create_issue
, p_http_method => ‘POST’
, p_username => l_gitlab_user
, p_password => l_gitlab_pw
, p_body => l_json_clob
, p_wallet_path => l_wallet_loc_nopass);
end;

Thank you,
Eric

Just a heads up, and hopefully its not real… but there appears to be a password in the text that you posted…

it is a fake password!! thanks

Anyone ?

It appears that Oracle PL/SQL does support contacting external URLs (HTTP and HTTPS) for REST calls: https://asktom.oracle.com/pls/apex/f?p=100:11:0::::P11_QUESTION_ID:9534133900346975204# and they appear to support JSON responses too (from my limited Oracle knowledge, so I may be incorrect).

Your example code appears to be doing the right things - have you tried running a simple operation to test? Do you encounter an error?

On the GitLab API service-end it does not matter what the client is, as long as the request is authorized and carries all the valid requirements (params, body, etc.).

Hi Harsh,

I have a similar working example using GitHub API, but now I need one for GitLab.

When I run my script I am getting this error now:

{“message”:“401 Unauthorized”}

Moreover, I don’t know how to pass the token on the code.

Thank you,
Eric

I put it to work, after adding the token

apex_web_service.g_request_headers(2).name := ‘PRIVATE-TOKEN’;
apex_web_service.g_request_headers(2).Value := ‘blablablablabla’;

Thank you.