janenz00
janenz00

Reputation: 3310

jasper Rest client - uuid not found in session

I have to code a PHP front end for my Jasper reports. I could successfully connect to the server, authenticate and view the repositories using the jasper REST calls. However, when I try to access a report, I get the following error in the response body:

Report not found (uuid not found in session)

The php code is given below:

   $uri = "http://localhost:8080/jasperserver/rest/report/samples/Client_Information_Report?RUN_OUTPUT_FORMAT=html";

    //PUT request to run the report
    $response = Httpful\Request::put($uri, $payload)
    ->authenticateWith("jasperadmin", "jasperadmin")
    ->send();

    $xml = new SimpleXMLElement($response->body);
    $uuid = (String)$xml->uuid; //The uuid is successfully returned

    $uri = "http://localhost:8080/jasperserver/rest/report/$uuid?file=report";
    $report = Httpful\Request::get($uri)
              ->authenticateWith("jasperadmin", "jasperadmin")
              ->send();

I am able to confirm that a uuid is returned with the first PUT. Is there anything I am missing here? Any help is appreciated.

Upvotes: 1

Views: 1661

Answers (1)

MarianoL
MarianoL

Reputation: 36

Janenz,

First check the info that is coming from the PUT response to see if there is actually a report being generated and that is not empty, you should receive something like this:

<report>
    <uuid>d7bf6c9-9077-41f7-a2d4-8682e74b637e</uuid>
    <originalUri>/reports/samples/AllAccounts</originalUri>
    <totalPages>43</totalPages>
    <startPage>1</startPage>
    <endPage>43</endPage>
    <file type="image/png">img_0_0_0</file>
    <file type="image/gif">px</file>
    <file type="text/html">report</file>
    <file type="image/jpeg">img_0_42_27</file>
    <file type="image/png">img_0_42_26</file>
</report>

Notice the number of pages and the files available.

I have not used the Httpful library, but another thing to check is the way that library uses the Basic Authentication. It may happen that the second call is logging you in again and creating a new session; that is why you cannot find the UUID of the current session.

I have a full JasperServer and PHP sample in GitHub that you can check, it has the repository browsing and input control rendering implemented. I'm not sure what version of JasperReports Server you are using but in the new version there is a new REST API that makes requesting reports a lot easier; check the JasperReports Server Web Services Guide (Section 3.2). I have that implemented in the JRS-Wrapper Branch of my project.

Hope this helps!!

MarianoL

Upvotes: 2

Related Questions