PHP Client - PHP Fatal error: Uncaught exception 'Jasper\\RESTRequestException' with message 'Unexpected HTTP code returned: 401 Body of response:

Hi Everybody!
 
According to Samples from:
 
 
Yesterday I felt a little bit curious about testing Jasper Client, so I started using following code:
 
<?php
 
require_once "rest/client/JasperClient.php";
 
$client = new Jasper\JasperClient('report.myserver.com',
                 80,
                'myuser',
                'mypassword',
                '/jasperserver-pro',
                'organization_1');
 
 
$repository = $client->getRepository();
 
var_dump($repository);
 
?>
 
But the Apache Error Log is yelling me with an error like this one:
 
[Thu Sep 19 10:14:29 2013] [error] [client 127.0.0.1] PHP Fatal error:  Uncaught exception 'Jasper\\RESTRequestException' with message 'Unexpected HTTP code returned: 401 Body of response: Apache Tomcat/7.0.40 - Error report HTTP Status 401 - Full authentication is required to access this resourcetype Status reportmessage Full authentication is required to access this resourcedescription This request requires HTTP authentication.Apache Tomcat/7.0.40' in /var/www/jasperreports/htdocs/rest/client/JasperClient.php:133\nStack trace:\n#0 /var/www/jasperreports/htdocs/rest/client/JasperClient.php(587): Jasper\\JasperClient->prepAndSend('http://report.s...', Array, 'GET', NULL, true)\n#1 /var/www/jasperreports/htdocs/info.php(13): Jasper\\JasperClient->getRepository()\n#2 {main}\n  thrown in /var/www/jasperreports/htdocs/rest/client/JasperClient.php on line 133
 
I just double checked host, username, password and org and everything seems right.
 
Do I am missing something here?
 
Thanks in advance.
 
porozco's picture
Joined: Sep 10 2013 - 4:05pm
Last seen: 9 years 6 months ago

I am also facing the same issue for this PHP client. Any solution please

ahesanbvm - 6 years 12 months ago

2 Answers:

Hello!

I'm trying to do something like this:

<?PHP
ini_set('display_errors',1);ini_set('display_startup_errors',1);error_reporting(E_ALL);require_once "vendor/autoload.php";
use Jaspersoft\Client\Client;
$c = new Client(        "localhost",        "8082",        "jasperadmin",        "jasperadmin",        "/jasperserver",        "organization_1"      );
$info = $c->serverInfo();
print_r($info);
 
?>

i have a similar error:

Fatal error: Uncaught exception 'Jaspersoft\Exception\RESTRequestException' with message 'Unexpected HTTP code returned: 401 Body of response: Apache Tomcat/7.0.42 - Error report HTTP Status 401 - Bad credentialstype Status reportmessage Bad credentialsdescription This request requires HTTP authentication.Apache Tomcat/7.0.42' in /home/lucas/projects/integracao/vendor/jaspersoft/rest-client/src/Jaspersoft/Tool/RESTRequest.php:431 Stack trace: #0 /home/lucas/projects/integracao/vendor/jaspersoft/rest-client/src/Jaspersoft/Service/JobService.php(86): Jaspersoft\Tool\RESTRequest->prepAndSend('http://localhos...', Array, 'GET', NULL, true, 'application/job...', 'application/job...') #1 /home/lucas/projects/integracao/index.php(20): Jaspersoft\Service\JobService->getJob('/reports/listae...') #2 {main} thrown in /home/lucas/projects/integracao/vendor/jaspersoft/rest-client/src/Jaspersoft/Tool/RESTRequest.php on line 431

Anyone know how to fix it?

llucas_gs's picture
Joined: Nov 26 2013 - 9:38am
Last seen: 9 years 3 months ago
rajeshree.kanojiya's picture
Joined: Nov 24 2016 - 11:04pm
Last seen: 5 years 12 months ago
Feedback