[#198] Access denied error when I'm trying to pull data through API

Migrated from Redmine #198 | Author: Dan Dev
Status: New | Priority: High, I’m very impatient | Created: 2018-07-23


Hello!
I’m trying to integrate simplybook calendar with my client’s recruiting system. My code get access token and $client object, but when I call any function to retrieve actual data I’m getting an error “Access denied”.

Here is my code:

$loginClient = new JsonRpcClient(‘https://user-api.simplybook.me’ . ‘/login/’);
$token = $loginClient->getUserToken($LOGIN, $USER_LOGIN, $USER_PASSWORD);

echo $token;

$client = new JsonRpcClient('https://user-api.simplybook.me' . '/admin/', array(
		'headers' => array(
		'X-Company-Login: ' . $LOGIN,
		'X-User-Token: ' . $token
	)
));

print_r($client);

$services = $client->getEventList();

echo "<pre>";

print_r($services);

echo "</pre>";

And here is server’s respond:

23033289dc2d326e7f57cafd89b0829e2b94345414927e67dd505d309ec75e48JsonRpcClient Object ( [_requestId:protected] => 1 [_contextOptions:protected] => Array ( [http] => Array ( [method] => POST [header] => Content-type: application/json X-Company-Login: DanDev X-User-Token: 23033289dc2d326e7f57cafd89b0829e2b94345414927e67dd505d309ec75e48 ) ) [_url:protected] => https://user-api.simplybook.me/admin/ )
Fatal error: Uncaught exception ‘Exception’ with message ‘Request error: Access denied’ in /home/linguedo/public_html/new-version/scripts/checking1.php:57 Stack trace: #0 /home/linguedo/public_html/new-version/scripts/checking1.php(87): JsonRpcClient->__call(‘getEventList’, Array) #1 /home/linguedo/public_html/new-version/scripts/checking1.php(87): JsonRpcClient->getEventList() #2 {main} thrown in /home/linguedo/public_html/new-version/scripts/checking1.php on line 57

Thank you!

Redmine Admin wrote:

found no company with login DanDev

Dan Dev wrote:

Redmine Admin wrote:

found no company with login DanDev

Here is a schreenshot of my accounts profile (and - yes, I’ve tried to use the company name dandave (in lowercase) instead of DanDav, that doesn’t work either). Strange, I just logged in using the same credentials.

Actually I’ve registered this account a few days ago just to try out if simplybook is a good fit for my client. Once I’ll get the integration working, my client will register his company’s account.

Dan Dev wrote:

Dan Dev wrote:

Redmine Admin wrote:

found no company with login DanDev

Here is a schreenshot of my accounts profile (and - yes, I’ve tried to use the company name dandave (in lowercase) instead of DanDav, that doesn’t work either). Strange, I just logged in using the same credentials.

Actually I’ve registered this account a few days ago just to try out if simplybook is a good fit for my client. Once I’ll get the integration working, my client will register his company’s account.

Strange, cannot attach the image here, will upload to some server and insert here a link.

Dan Dev wrote:

Here is the link - http://linguedo.eu/new-version/Screenshot.png

Redmine Admin wrote:

ok, then it is clear. You need to use user-api.simplybook.it (not me) as endpoint and dandev in lowercase

Dan Dev wrote:

Redmine Admin wrote:

ok, then it is clear. You need to use user-api.simplybook.it (not me) as endpoint and dandev in lowercase

It works, thank you!
By the way, maybe it would be useful to update the API’s documentation to avoid confusing other developers in the future. Or changing the endpoint url was necessarily only in this specific case?

Anyway, thank your very much!
Cheers!