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 Jaspersoft\Client\Client; $c = new Client("my-server-ip", "my-username", "my-password"); $info = $c->serverInfo(); printf($info); ?>
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 'Jaspersoft\Exception\RESTRequestException' 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): Jaspersoft\Tool\RESTRequest->handleError(0, Array, false) #1 /var/www/html/jaspersoft-php/src/Jaspersoft/Client/Client.php(158): Jaspersoft\Tool\RESTRequest->prepAndSend('http://my-ip...', Array, 'GET', NULL, true, 'application/jso...', 'application/jso...') #2 /var/www/html/jaspersoft-php/index.php(22): Jaspersoft\Client\Client->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!
7 Answers:
Please tell me how to resolve this issue;
Fatal error: Uncaught exception 'Jaspersoft\Exception\RESTRequestException' with message 'An unexpected HTTP status code was returned by the server' in C:\xampp\htdocs\sample\src\Jaspersoft\Tool\RESTRequest.php:378 Stack trace: #0 C:\xampp\htdocs\sample\src\Jaspersoft\Tool\RESTRequest.php(451): Jaspersoft\Tool\RESTRequest->handleError(0, Array, false) #1 C:\xampp\htdocs\sample\src\Jaspersoft\Client\Client.php(158): Jaspersoft\Tool\RESTRequest->prepAndSend('http://192.168....', Array, 'GET', NULL, true, 'application/jso...', 'application/jso...') #2 C:\xampp\htdocs\sample\sample.php(15): Jaspersoft\Client\Client->serverInfo() #3 {main} thrown in C:\xampp\htdocs\sample\src\Jaspersoft\Tool\RESTRequest.php on line 378
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 Jaspersoft\Client\Client;
//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;
?>
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 ) Jaspersoft\Exception\RESTRequestException 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:\xampp\htdocs\lsp\site\local\reports\jrs-rest-php-client-master\src\Jaspersoft\Tool\RESTRequest.php [line:protected] => 409 [trace:Exception:private] => Array ( [0] => Array ( [file] => C:\xampp\htdocs\lsp\site\local\reports\jrs-rest-php-client-master\src\Jaspersoft\Tool\RESTRequest.php [line] => 479 [function] => handleError [class] => Jaspersoft\Tool\RESTRequest [type] => -> [args] => Array ( [0] => 0 [1] => Array ( [0] => 200 ) [2] => ) ) [1] => Array ( [file] => C:\xampp\htdocs\lsp\site\local\reports\jrs-rest-php-client-master\src\Jaspersoft\Service\ReportService.php [line] => 40 [function] => prepAndSend [class] => Jaspersoft\Tool\RESTRequest [type] => -> [args] => Array ( [0] => http://localhost:8080/jasperserver/rest_v2/reports/ContentFiles/html/Tea... [1] => Array ( [0] => 200 ) [2] => GET [3] => [4] => 1 ) ) [2] => Array ( [file] => C:\xampp\htdocs\lsp\site\local\reports\teacherperformancereport.php [line] => 146 [function] => runReport [class] => Jaspersoft\Service\ReportService [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