Skip to Main Content

APEX

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to extract and save Excel file from a cloud system in APEX using APEX_WEB_SERVICE.make_rest_request_b

Wei QinJul 16 2024

Hello APEX guru,

I am trying to use APEX package APEX_WEB_SERVICE.make_rest_request_b to extract and save Excel attachment files from a cloud system, see an example below. After calling the API with a Bearer token and headers specification in Postman, I can “save response to file” to save the API call response to an Excel file, no problem. I wonder how I do this in APEX using package APEX_WEB_SERVICE.make_rest_request_b ?

I used APEX_WEB_SERVICE.make_rest_request to call many APIs to return JSON responses, no problem, but returning binary attachment files such as Excel or PDF files is something I need help.

I used the following APEX codes to call the API, but nothing returned and g_status_code is null.

begin
apex_web_service.g_request_headers.delete;
apex_web_service.g_request_headers(1).name := 'Authorization';
apex_web_service.g_request_headers(1).value := 'Bearer '||l_token;
apex_web_service.g_request_headers(2).name := 'abcd-Company-Id';
apex_web_service.g_request_headers(2).value := '427289867676';
l_blob := APEX_WEB_SERVICE.make_rest_request_b(
p_url => 'https://abcd.com/v4/d/us-east-1/pro-core.com/prostore/20240709193835_production-us02_2aacea337f3d8ab0d20cf6e2df5cb355ea37?sig=6d6cb0c49ed71a4859bab3ffce97d73f3912245f930733ba7b29a6ba97fb3db6&abcd-Company-Id=42728987676',
p_http_method => 'GET',
p_wallet_path => 'file:/opt/oracle/wallet',
p_wallet_pwd => ‘abcdefg’
) ;
exception
when others then

dbms_output.put_line('ERROR: '||apex_web_service.g_status_code);
end;
dbms_output.put_line('g_status_code='||apex_web_service.g_status_code);
…..

Comments
Post Details
Added on Jul 16 2024
0 comments
260 views