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 get Response from apex_web_service.make_rest_request??

MehabubRSheikhNov 12 2020

Hi,
I have a NodeJS application which host my REST Webservice to return a PDF document as a Base64 encoded string data. I am calling this web service from APEX using the following code
DECLARE
l_cursor SYS_REFCURSOR;
l_body_clob clob;
l_resp_clob clob;
l_blob BLOB := empty_blob();
--l_blob BLOB;
l_step number := 22500;
BEGIN
DBMS_LOB.OPEN(l_blob, DBMS_LOB.LOB_READONLY);
OPEN l_cursor FOR
SELECT cust.customer_name,
cursor(select
products.product_name
,case
when products.uom_type ='RANGE_VALUE' then
products.range_low||products.uom||'-'||products.range_high||products.uom
else
products.absolute_value||products.uom
end reference_range
from xxdiag.xxeba_patient_order_lines_all lines,
xxdiag.eba_cust_products products,
xxdiag.eba_cust_product_families fam
where orders.order_header_id = lines.order_id
and lines.product_id = products.id
and products.product_family_id = fam.id) lines
FROM xxdiag.eba_cust_customers cust,
xxdiag.xxeba_patient_orders orders
WHERE orders.customer_id = cust.id;
APEX_JSON.initialize_clob_output;

APEX_JSON.open_object;
APEX_JSON.write('orders', l_cursor);
APEX_JSON.close_object;
l_body_clob := APEX_JSON.get_clob_output;
apex_web_service.g_request_headers.delete();
apex_web_service.g_request_headers(1).name := 'Content-Type';
apex_web_service.g_request_headers(1).value := 'application/json';
apex_web_service.g_request_headers(2).name := 'TemplateName';
apex_web_service.g_request_headers(2).value := 'Biochemistry';
l_resp_clob := apex_web_service.make_rest_request(
p_url => '***' - the REST WebService URL
p_http_method => 'POST',
p_body => l_body_clob
);
DBMS_OUTPUT.put_line('Response:'||l_resp_clob);
APEX_JSON.free_output;

END;
But I am not able capture the response. When I call the same web service using soapui I get the response.
Could you please help me?

Thanks,
Mehabub

This post has been answered by APEX4EBS on Nov 12 2020
Jump to Answer

Comments

APEX4EBS
Answer

Check : apex_web_service.g_status_code
This will give you the status code. Use the number to help determine the issue.

Marked as Answer by MehabubRSheikh · Nov 12 2020
MehabubRSheikh

Thanks for the guidance. I was getting return status 400 and I could figure out the mistake. I corrected it and now it is working as expected.
Thanks for your help.

Mehabub

1 - 2

Post Details

Added on Nov 12 2020
2 comments
7,637 views