I have requirement to call the rest API hosted on Oracle Management Cloud (OMC) in Apex. It needs OCNA access. (oracle cloud network access).
I am able to invoke the service on postman with basic authentication after connecting to OCNA - https://myaccess.oracle-ocna.com/.
Connecting to OCNA is mandatory to call the OMC REST APIs.
tried with following code:
create or replace package body "METRIC_ANALYTICS" is
procedure START_OMC_EXTRAT(param1 IN VARCHAR2, p_response OUT CLOB)
as
v_api VARCHAR2(3000) := 'https://faprod-omcsaasiad.saas.omc.ocp.oraclecloud.com/serviceapi/querylanguage.query';
begin
apex_web_service.g_request_headers.delete;
apex_web_service.g_request_headers(1).name := 'Accept';
apex_web_service.g_request_headers(1).value := 'application/json';
apex_web_service.g_request_headers(2).name := 'Content-Type';
apex_web_service.g_request_headers(3).value := 'application/x-www-form-urlencoded; charset=UTF-8';
p_response := apex_web_service.make_rest_request(
p_url => v_api,
p_http_method => 'POST',
p_scheme => 'Basic',
p_body => '{
"queryTimeout": 300,
"subSystem": "LOG",
"maxTotalCount": 20000,
"includeFields": true,
"outputMode": "JSON",
"queryString": "''Log Group'' not like in (''%dev%'', ''%test%'') and Entity like ''*ESS_SOAServer*'' and ''Entity Type'' = ''WebLogic Server'' and ''Original Log Content'' = selectionFailure and ''Original Log Content'' in (FinExmWorkflowExpenseApprovalComposite, FinApInvTransactionsInvoiceApprovalComposite) and ''Log Source'' = ''FMW WLS Server Diagnostic Logs''",
"includeTotalCount": true,
"includeColumns": false,
"timeFilter": {
"startTime": "2022-09-08T12:00:00.000Z",
"endTime": "2022-09-09T12:00:00.000Z",
"type": "absolute"
}
}',
p_username => 'ClickStream',
p_password => 'OutcomeTele1'
);
--p\_wallet\_path => v\_wallet\_path,
--p\_wallet\_pwd => v\_wallet\_pwd );
--l\_data := dbms\_lob.substr( l\_response, 4245, 1 );
dbms_output.put_line( 'status_code = ' || apex_web_service.g_status_code);
exception
when others then
dbms_output.put_line('GET_BUG_APP.START_OMC_EXTRAT:'||sqlerrm);
end START_OMC_EXTRAT;
end METRIC_ANALYTICS;
But Failed with following error:
ORA-29273: HTTP request failed