Hello folks,
please see below piece of code, from oracle package to run a test report from jasperserver.
Unfortunately I'm getting an "500 Internal Server Error" error. I think a problem is with an authentication. Please suggest what might be wrong.
Tomas
Test code:
procedure report_execution_test is
t_http_req utl_http.req;
t_http_resp utl_http.resp;
t_request_body varchar2(30000);
t_respond varchar2(30000);
t_start_pos integer := 1;
t_output varchar2(2000);
begin
t_request_body :=
'<reportExecutionRequest>
<reportUnitUri>/reports/reports/AGL/rep_pj_fa_vykon</reportUnitUri>
<async>true</async>
<freshData>false</freshData>
<saveDataSnapshot>false</saveDataSnapshot>
<outputFormat>html</outputFormat>
<interactive>true</interactive>
<ignorePagination>false</ignorePagination>
<pages>1-5</pages>
<parameters>
<reportParameter name="P_RIDIC_ID">
<value>381045</value>
</reportParameter>
<reportParameter name="P_ROKMES">
<value>2015/02</value>
</reportParameter>
</parameters>
</reportExecutionRequest>';
/*Telling Oracle where the webservice can be found, what kind of request is made
and the version of the HTTP*/
t_http_req:= utl_http.begin_request( 'http://my_server:port/jasperserver/rest_v2/reportExecutions'
, 'POST' --'POST'
, 'HTTP/1.1');
--utl_http.set_authentication(t_http_req,'username','password');
--utl_http.set_authentication(t_http_req,'jasperadmin','jasperadmin');
utl_http.set_header(t_http_req,'Authorization','amFzcGVyYWRtaW46amFzcGVyYWRtaW4=','Basic');
/*Describe in the request-header what kind of data is send*/
utl_http.set_header(t_http_req, 'Content-Type', 'text/xml charset=UTF-8');
--utl_http.set_header(t_http_req, 'Content-Type', 'application/x-www-form-urlencoded');
/*Describe in the request-header the lengt of the data*/
utl_http.set_header(t_http_req, 'Content-Length', length(t_request_body));
/*Put the data in de body of the request*/
utl_http.write_text(t_http_req, t_request_body);
/*make the actual request to the webservice en catch the responce in a
variable*/
t_http_resp:= utl_http.get_response(t_http_req);
--utl_http.read_text(t_http_resp, t_respond, 32767);
dbms_output.put_line(t_http_resp.status_code||' '||t_http_resp.reason_phrase );
utl_http.end_response(t_http_resp);
end;