Jump to content
Changes to the Jaspersoft community edition download ×

REST v2 API / PHP Client Errors


Recommended Posts

I'm using JasperSoft Studio Community Edition (6.3.1 final) and have the Community edition of JasperServer.

I have created reports and successfully published them from Studio to the server. I've also been able to review the reports on the actual server itself through the web app.

My next step is to use the Rest v2 API to display my reports in a project but I've been unsuccessful.

Here is my code (trying to display the server info):

<?php require_once("autoload.dist.php"); use JaspersoftClientClient; $c = new Client("my-server-ip", "my-username", "my-password"); $info = $c->serverInfo(); printf($info); ?>[/code]

I removed the organization because there is no organization associated with my account and having the organization parameter would return a 404 error.

Upon testing this code, I receive the following message:

Fatal error: Uncaught exception 'JaspersoftExceptionRESTRequestException' with message 'An unexpected HTTP status code was returned by the server' in /var/www/html/jaspersoft-php/src/Jaspersoft/Tool/RESTRequest.php:378 Stack trace: #0 /var/www/html/jaspersoft-php/src/Jaspersoft/Tool/RESTRequest.php(451): JaspersoftToolRESTRequest->handleError(0, Array, false) #1 /var/www/html/jaspersoft-php/src/Jaspersoft/Client/Client.php(158): JaspersoftToolRESTRequest->prepAndSend('http://my-ip...', Array, 'GET', NULL, true, 'application/jso...', 'application/jso...') #2 /var/www/html/jaspersoft-php/index.php(22): JaspersoftClientClient->serverInfo() #3 {main} thrown in /var/www/html/jaspersoft-php/src/Jaspersoft/Tool/RESTRequest.php on line 378

 

Does anyone have any ideas as to why this is happening? I've been stuck on this issue for a day now and would like to get to the bottom of it.

Thank you in advance!

 

 

Link to comment
Share on other sites

  • Replies 8
  • Created
  • Last Reply

Top Posters In This Topic

  • 5 weeks later...

Please tell me how to resolve this issue;

Fatal error: Uncaught exception 'JaspersoftExceptionRESTRequestException' with message 'An unexpected HTTP status code was returned by the server' in C:xampphtdocssamplesrcJaspersoftToolRESTRequest.php:378 Stack trace: #0 C:xampphtdocssamplesrcJaspersoftToolRESTRequest.php(451): JaspersoftToolRESTRequest->handleError(0, Array, false) #1 C:xampphtdocssamplesrcJaspersoftClientClient.php(158): JaspersoftToolRESTRequest->prepAndSend('http://192.168....', Array, 'GET', NULL, true, 'application/jso...', 'application/jso...') #2 C:xampphtdocssamplesample.php(15): JaspersoftClientClient->serverInfo() #3 {main} thrown in C:xampphtdocssamplesrcJaspersoftToolRESTRequest.php on line 378

Link to comment
Share on other sites

i am new to this i dont undertstand how to do it .

 

i have created the report and tried in server .i used this code with php client  jrs-rest-php-client-2.0.0 after downloading i had written a php file and run through xampp .

 

<?php
/*ini_set('display_errors',1);ini_set('display_startup_errors',1);error_reporting(E_ALL);
*///require_once __DIR__ . "/autoload.dist.php";
  require_once("autoload.dist.php");
use JaspersoftClientClient;
 //require_once "src/Jaspersoft/Client/Client.php";

/*    try {   */
    $d = new Client(
                "http://localhost:8080/jasperserver",
                "jasperadmin",
                "jasperadmin"  ,""
            );

    $info = $d->serverInfo();
  printf($info);
/*} catch (RESTRequestException $e) {
    echo 'RESTRequestException:';
    echo 'Exception message:   ',  $e->getMessage(), "n";
    echo 'Set parameters:      ',  $e->parameters, "n";
    echo 'Expected status code:',  $e->expectedStatusCodes, "n";
    echo 'Error code:          ',  $e->errorCode, "n";
}
 $conts=array("agtid"=>2);

$report = $c->reportService()->runReport('/reports/samples/Cascading_multi_select_report',"pdf",null,null,$conts);
*/
//echo $report;
?>

Link to comment
Share on other sites

  • 3 months later...
  • 10 months later...
  • 1 month later...
  • 3 years later...

Hi ,

What is the solution for this problem?  Facing this issue for one report when trying to run the report using one of the parameter.

Received following message:RESTRequestException:Exception message: An unexpected HTTP status code was returned by the server Set parameters: Expected status code:Array Error code: Array ( [0] => 200 ) JaspersoftExceptionRESTRequestException Object ( [message] => An unexpected HTTP status code was returned by the server [expectedStatusCodes] => Array ( [0] => 200 ) [statusCode] => 0 [jrsMessage] => [errorCode] => [parameters] => [string:Exception:private] => [code:protected] => 0 [file:protected] => C:xampphtdocslspsitelocalreportsjrs-rest-php-client-mastersrcJaspersoftToolRESTRequest.php [line:protected] => 409 [trace:Exception:private] => Array ( [0] => Array ( [file] => C:xampphtdocslspsitelocalreportsjrs-rest-php-client-mastersrcJaspersoftToolRESTRequest.php [line] => 479 [function] => handleError [class] => JaspersoftToolRESTRequest [type] => -> [args] => Array ( [0] => 0 [1] => Array ( [0] => 200 ) [2] => ) ) [1] => Array ( [file] => C:xampphtdocslspsitelocalreportsjrs-rest-php-client-mastersrcJaspersoftServiceReportService.php [line] => 40 [function] => prepAndSend [class] => JaspersoftToolRESTRequest [type] => -> [args] => Array ( [0] => http://localhost:8080/jasperserver/rest_v2/reports/ContentFiles/html/TeacherPerformanceReport.html?interactive=true&onePagePerSheet=true&freshData=true&saveDataSnapshot=false&trackId=1 [1] => Array ( [0] => 200 ) [2] => GET [3] => [4] => 1 ) ) [2] => Array ( [file] => C:xampphtdocslspsitelocalreportsteacherperformancereport.php [line] => 146 [function] => runReport [class] => JaspersoftServiceReportService [type] => -> [args] => Array ( [0] => /ContentFiles/html/TeacherPerformanceReport [1] => html [2] => [3] => [4] => Array ( [trackId] => Array ( [0] => 1 ) ) [5] => 1 [6] => 1 ) ) ) [previous:Exception:private] => )

Report run successfully for other parameters.

Kindly help. Thanks in Advance

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...