Wednesday, November 10, 2021

Read REST data using XML input to PLSQL

declare
l_value varchar2(4000);
begin

for x in (select *
from xmltable(
   '/Entities/Entity/Fields/Field'
   passing xmltype(get_rest_details('http:///....us.xyz.com/q...../...//....'))
   COLUMNS
   name varchar2(4000) path '@Name',
   value varchar2(4000) path 'Value'
)
)
loop
htp.p(x.name||chr(9)||chr(9)||'=>'||x.value);
end loop;
exception when others then
htp.p(sqlerrm);

end;

 

-- get_rest_details is a procedure that performs authentication and call REST service
Source: https://docs.oracle.com/cd/E37097_01/doc.42/e35127/GUID-4AC0229D-85E2-439A-9485-531B7B8B6274.htm#AEAPI1955

Example:

l_clob := apex_web_service.make_rest_request(
        p_url => 'http://us.music.yahooapis.com/ video/v1/list/published/popular',
        p_http_method => 'GET',
        p_parm_name => apex_util.string_to_table('appid:format'),
        p_parm_value => apex_util.string_to_table('xyz:xml'));

No comments:

Post a Comment

Please add value. Sharing is caring