Jump to content
Changes to the Jaspersoft community edition download ×

jrs-rest-php-client - HTTP Status 401 - Full authentication is required to access this resource


porozco

Recommended Posts

Hello Everyone,

Today I felt some curiosity about:

https://github.com/Jaspersoft/jrs-rest-php-client

Thats why I just cloned and set-up autoload.php to start testing this Client. 

Here is my code:

<?php
 
error_reporting(E_ALL);
ini_set('display_errors', '1');
 
require_once __DIR__ . "/vendor/autoload.php";
 
use JaspersoftClientClient;
 
$c = new Client(
        "report.myserver.com",
        "80",
        "username",
        "password",
        "/jasperserver-pro",
        "organization_1"
      );
 
//$info = $c->serverInfo();
//print_r($info);
 
$r = $c->repositoryService()->resourceSearch();
 
//print_r($repo);
 
?>

But I am having a response with error: HTTP Status 401 - Full authentication is required to access this resource. I just double checked username, password and org, and everything seems right. So testing, for example with:

curl -D- -u username:password -X GET http://report.myserver.com:80/jasperserver-pro/rest/resources

http://report.myserver.com:80/jasperserver-pro/rest/resources?j_username=username&j_password=password

Is responding right, with an XML response of resource descriptors.

Another interesting thing I found debugging (var_dump) function setCurlOpts in RESTRequest.php is  that $this->url is:

http://report.myserver.com:80/jasperserver-pro/rest_v2/resources

and not:

http://report.myserver.com:80/jasperserver-pro/rest/resources

which responds with a not found status.

I also tried adding some Authorization: Basic to CURLOPT_HTTPHEADER.

protected function setAuth (&$curlHandle)
{
if ($this->username !== null && $this->password !== null)
{
curl_setopt($curlHandle, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($curlHandle, CURLOPT_USERPWD, $this->username . ':' . $this->password);
 
curl_setopt($curlHandle, CURLOPT_HTTPHEADER, array("Authorization: Basic " . base64_encode($this->username . ":" . $this->password)));
 
}
}

But no succesful response is back. By the way, Passing variables by reference is a deprecated issue to worry about? Even if my php 5.5.1-2 is not yelling about it.

Thanks in advance.

 

 

Link to comment
Share on other sites

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Hi Pablo,

The jrs-rest-php-client on github currently has repositoryService and Resource services which are expected to work with the next release of JRS Pro.

You can develop code and test it against the latest trunk build for the community edition if you would like to develop prior to the next release. If you checkout the tag for "lastSuccessfulBuild-trunk" or "lastReviewed-trunk" (stable version) below, you can build the community edition which will support the latest php client.

Link to public SVN: http://anonsvn:anonsvn@code.jaspersoft.com/svn/repos/jasperserver

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...