REST v2 API / PHP Client Errors

0

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!

daniel.la's picture
Joined: Jan 19 2017 - 11:36am
Last seen: 1 year 9 months ago

7 Answers:

0

nevermind. solved it

daniel.la's picture
Joined: Jan 19 2017 - 11:36am
Last seen: 1 year 9 months ago
0

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

germanmary.p's picture
Joined: Aug 24 2017 - 4:11am
Last seen: 1 year 11 months ago
-1

It seems like you're developing locally. Can you test this on a live server? I had the same issues when developing locally, none of my reports would display.

daniel.la's picture
Joined: Jan 19 2017 - 11:36am
Last seen: 1 year 9 months ago
0

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;
?>

germanmary.p's picture
Joined: Aug 24 2017 - 4:11am
Last seen: 1 year 11 months ago
0

I have the same error. Is there anyone who can suggest something to solve this issue ? Thanks.

 

sterlingman2001's picture
Joined: Jun 16 2017 - 5:25am
Last seen: 1 year 2 months ago
0

It's a pity that the jasperserver community could not find a solution! I just want to connect php7 with jasperserver7, use httpd in linux centos 7 (64bits). I'm showing the same error. Any light will be welcome

polexito2002_1's picture
Joined: Apr 17 2018 - 8:15am
Last seen: 9 months 2 days ago
0

Use User: jasperadmin and Password: jasperadmin

I don't no why but only this user works. 

thomas.frommelt's picture
Joined: Jan 21 2013 - 12:44am
Last seen: 3 days 13 hours ago
Feedback