Skip to Main Content

General Cloud Infrastructure

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 send an XML to Oracle BI Publisher throught the RESTful API and retrieve the pdf ?

Daniel GagnonMay 29 2023 — edited Jun 1 2023

Hello,

we are searching a way to write a function that will call a BI Publisher report and retrieve the pdf to user for consumption or storage. We have a special limit in our Cloud, we need to pass to BI publisher an XML that will contain all the datasets of the report. We used to have 3 differents development environments, but since we switched to the Cloud we will only have one environment and we would like to send our data regardless of our environment. Our goal is to get the data locally, export it in a file, call BI Publishe RESTFul API and get the generated file.

But so far, we could not make BIPublisher respond positively to our custom requests. We tried using the https://docs.oracle.com/middleware/12213/bip/BIPAP/op-v1-reports-%7BreportPath%7D-run-post.html examples. But I find it difficult to understand because there is no comprehensive example on how to code it. We only have made it respond to our call in google's API tester. We get the response with the file for a specific call.

Could you tell me what we are doing wrong with that code ?

declare
   v_req       utl_http.req;
   v_res       utl_http.resp;
   v_buffer    varchar2(4000); 
   v_body      varchar2(4000) := '--Boundary_5209_475599372_1685129796023
Content-Type: application/json
Content-Disposition: form-data; name="ReportRequest"
{"byPassCache":true,"flattenXML":false,"attributeFormat":"pdf"}
--Boundary_5209_475599372_1685129796023--'; -- Your JSON
begin
   -- Set connection.
   v_req := utl_http.begin_request('https://host/xmlpserver/services/rest/v1/reports/Reports%252Funit%252FAPP%252Frpt_test/run', 'POST');
   utl_http.set_authentication(v_req, 'user','password');
   
   utl_http.set_header(v_req, 'Content-type', 'multipart/form-data; boundary="Boundary_5209_475599372_1685129796023"'); 
   utl_http.set_header(v_req, 'Accept', 'multipart/form-data');
   utl_http.set_header(v_req, 'Content-Length', length(v_body));
   
   -- Invoke REST API.
   utl_http.write_text(v_req, v_body);
 
   -- Get response.
   v_res := utl_http.get_response(v_req);
   begin
       loop
           utl_http.read_line(v_res, v_buffer);
           -- Do something with buffer.
           dbms_output.put_line(v_buffer);
       end loop;
       utl_http.end_response(v_res);
   exception
       when utl_http.end_of_body then
           utl_http.end_response(v_res);
   end;
end;

Saddly, using the same parameters inside API Tester is working well, but not in PL/SQL, it gives an 415 Error or a 400 Error.

But it the end, I want to add an XML dataset within a call for this.

Thank you for your Help.

Comments
Post Details
Added on May 29 2023
5 comments
1,246 views