SuiteCRM V8 api returns false

Hello all,

I am trying with V8 api for the first time. Initially I have faced few issues such as 404 error and all. But I have solved those somehow with the help of fellow SuiteCRM developers. Now, I am using this script and when I var dump the output I get boolean false response. Kindly help me out here soon.


$ch = curl_init();
$header = array(
	'Content-type: application/vnd.api+json',
    'Accept: application/vnd.api+json' 
);
$postStr = json_encode(array(
'grant_type' => 'client_credentials',
'client_id' => '35fb0fd5-e5dc-3f0e-4ced-5c7d87cdda23',
'client_secret' => 'test',
'scope' => 'standard:create standard:read standard:update standard:delete standard:delete standard:relationship:create standard:relationship:read standard:relationship:update standard:relationship:delete'
));
$url = 'https://localhost/SuiteCRM-7.10.14/Api/V8/access_token';
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_POSTFIELDS, $postStr);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
$output = curl_exec($ch);

var_dump($output);

curl_close($ch);

Hi,
Can you first try to do it as “http” instead of “https”

Like

http://localhost/SuiteCRM-7.10.14/Api/V8/access_token

Thank you for replying. I have tried your solution and now I have received response. But it’s nothing but bunch of “Notices” and “Fatal” error. Below are the complete response.


string(1371) "

Notice:  Key file "file://C:\xampp\htdocs\SuiteCRM-7.10.14/Api/V8/OAuth2/private.key" permissions are not correct, should be 600 or 660 instead of 666 in C:\xampp\htdocs\SuiteCRM-7.10.14\vendor\league\oauth2-server\src\CryptKey.php on line 57

Notice:  Key file "file://C:\xampp\htdocs\SuiteCRM-7.10.14/Api/V8/OAuth2/public.key" permissions are not correct, should be 600 or 660 instead of 666 in C:\xampp\htdocs\SuiteCRM-7.10.14\vendor\league\oauth2-server\src\CryptKey.php on line 57

Notice:  Key file "file://C:\xampp\htdocs\SuiteCRM-7.10.14/Api/V8/OAuth2/public.key" permissions are not correct, should be 600 or 660 instead of 666 in C:\xampp\htdocs\SuiteCRM-7.10.14\vendor\league\oauth2-server\src\CryptKey.php on line 57

Fatal error:  Uncaught RuntimeException: Unexpected data in output buffer. Maybe you have characters before an opening <?php tag? in C:\xampp\htdocs\SuiteCRM-7.10.14\vendor\slim\slim\Slim\App.php:624
Stack trace:
#0 C:\xampp\htdocs\SuiteCRM-7.10.14\vendor\slim\slim\Slim\App.php(334): Slim\App->finalize(Object(Slim\Http\Response))
#1 C:\xampp\htdocs\SuiteCRM-7.10.14\Api\index.php(4): Slim\App->run()
#2 {main}
  thrown in C:\xampp\htdocs\SuiteCRM-7.10.14\vendor\slim\slim\Slim\App.php on line 624

"

It is giving fatal error in vendor code.

Can you please try by setting CRM files permissions

Navigate to root directory of CRM by Terminal on your server and run the following 2 commands

sudo chown -R www-data:www-data .
sudo chmod -R 755 .
sudo chmod -R 775 cache custom modules themes data upload config_override.php

Remember:
www-data means your apache User and Group name, Change it accordingly as per your Server Apache User Name.

and try it again.
Thanks

I am using Windows machine. May I know how to set file permission on Windows please? I couldn’t find any suitable resources for that.

Thank you.

1 Like

This error:
Fatal error: Uncaught RuntimeException: Unexpected data in output buffer. Maybe you have characters before an opening <?php tag? in C:\xampp\htdocs\SuiteCRM-7.10.14\vendor\slim\slim\Slim\App.php:624
Stack trace:
appears to be caused by manually entering your config.php by cutting and pasting from the web installer. I’m guessing that you have some additional blank lines at the end of the file that need to be removed.

Hi All,

I was facing the same error when I tried to execute V8 API’s through Postman.

Fatal error: Uncaught RuntimeException: Unexpected data in output buffer. Maybe you have characters before an opening <?php tag? in C:\xampp\htdocs\SuiteCRM-7.10.14\vendor\slim\slim\Slim\App.php:624
Stack trace:

After a lot of debug and google, finally I resolved that.

Step 1. Search for the file C:\xampp\htdocs<root folder name>\vendor\slim\slim\Slim\Container.php

Step 2. Search for addContentLengthHeader

You will find this here

Initially this value was set to true.

Step 3. Make it false.

Step 4. Run the token generation file. Token will be there as the output.