Problems with V8 Rest API

Hi anybody,

I try to follow the docs under https://docs.suitecrm.com/developer/api/version-8/configure-authentication/, part “Authentication with Client Credentials” , but with minor luck.

At first sight, it seems that the code is somehow wrong:

$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' => '3D7f3fda97-d8e2-b9ad-eb89-5a2fe9b07650',
    'client_secret' => 'client_secret',
));
$url = 'https://path-to-instance/Api/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);

replacing client_id, client secret and path-to-instance to my values, it only gives me an 500 error.

So I´ve modified it like this:


$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' => '3D7f3fda97-d8e2-b9ad-eb89-5a2fe9b07650',
   'client_secret' => 'client_secret',
));
$url = 'https://path-to-instance/Api/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);

Again replaced client_id, client secret and path-to-instance

Now i get an empty page.

If I var_dump the Results ( echo($output); ), i only get an “Forbidden-You do not have permission to access this document.” message.

Anybody any idea?

I use version 7.10.15

Problem solved, missing rights for the API folder.