Environment
PHP 7.x
MySQL 5.6
CentOS 6.9
Apache 2.4
SuiteCRM 7.10.4
I am trying to get 7.10.4 API V8 working. I’ve following the direction in the documentation as well as the code example. Below is the code:
******************************************** Code *****************************************************************
<?php
echo 'start'. "\n";
$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' => 'b0277ade-13ec-fabb-693a-aaaaaaaaa',
'client_secret' => 'myclientsecret',
'scope' => ''
));
$url = 'https://myurl.com/api/oauth/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);
echo "The response(output):\n";
print($output);
// Check HTTP status code
if (!curl_errno($ch)) {
switch ($http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE)) {
case 200: # OK
break;
default:
echo 'Unexpected HTTP code: ', $http_code, "\n";
}
}
curl_close($ch);
echo 'completed' . "\n";
print($postStr);
?>
*********************************************************ERROR MESSAGE *********************************************************************************
I receive the generic http error code of 500.
The following comes from the error log with logging level set to debug:
[19-Apr-2018 21:18:24 America/New_York] PHP Fatal error: Uncaught RuntimeException: Unexpected data in output buffer. Maybe you have characters before an opening <?php tag? in .../ensitecmdev03/vendor/slim/slim/Slim/App.php:604
Stack trace:
#0 .../ensitecmdev03/vendor/slim/slim/Slim/App.php(316): Slim\App->finalize(Object(Slim\Http\Response))
#1 .../ensitecmdev03/lib/API/core/app.php(83): Slim\App->run()
#2 .../ensitecmdev03/lib/API/public/index.php(5): require_once('/home/hhadmin/a...')
#3 {main}
thrown in .../ensitecmdev03/vendor/slim/slim/Slim/App.php on line 604
Any insight you may provide would be grateful.
Thank you,
Rod