Sugar - v9.0 Enterprise running on localhost using PHP v7.1.35
Wordpress custom plugin running on localhost using PHP v7.1.35
Ive got a strange problem with my local instance of sugar. I have a local copy of my live cloud install to facilitate development, however this morning I'm getting the following error when running any api call to my local sugar
{"error":"need_login","error_message":"No valid authentication for user."}
If i run the same API call in postman I get the proper return but my local wordpress app I get the error
PHP Error Log
[15-Jul-2019 10:12:41 UTC] Token: 24e46b36-541e-4246-9df7-56c904fd375c
[15-Jul-2019 10:12:41 UTC] URL: http://sugarcrm.localdev/rest/v11/Contact/SupportLogin
[15-Jul-2019 10:12:41 UTC] Data: {"Email":"test@test.com"} *this email exists in sugar as a test contact
[15-Jul-2019 10:12:41 UTC] Response: {"error":"need_login","error_message":"No valid authentication for user."}
My Curl call to the API endpoint "http://sugarcrm.localdev/rest/v11/Contact/SupportLogin"
static function getSugar($get,$url,$force = false) {
self::connect_sugarcrm();
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'GET' );
curl_setopt($curl, CURLOPT_POSTFIELDS, $get );
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
'Authorization: Bearer '.self::$tokens->access_token,
'Content-Type: application/json',
)
);
$json_response = curl_exec($curl);
$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
if (self::$log) {
_log('Token: '.self::$tokens->access_token);
_log('URL: '.$url);
_log('Data: '.$get);
_log('Response: '.$json_response);
};
curl_close($curl);
$result = json_decode($json_response);
return $result;
}
If i change my target url to my live sugar instance then everything works fine so this is a local issue just wandering if anyone else has come across this and found a fix. Ive also tried looking through the sugar log and there is nothing there that indicates a problem
if i run the API call in postman i get
{
"totalSize": 1,
"done": true,
"success": true,
"records": [
{
"attributes": {
"type": "Contacts",
"url": "/rest/v11/Contacts/0030W00003R7o81QAB"
},
"Id": "0030W00003R7o81QAB",
"Email": "test@test.com",
"Name": "Joe Bloggs",
"RegPass__c": "deleted the password string",
"Email_Invalid__c": 0
}
]
}