Started getting error from yesterday in login and another functions using rest api

Hi,

I am using rest api to feed the data in to SuiteCRM from website.

It was working quite fine till may10, 2017. After that same scripts started giving errors as below :

[i]Declaration of SugarWebServiceUtilv4::get_data_list() should be compatible with SugarWebServiceUtilv3_1::get_data_list($seed, $order_by = ‘’, $where = ‘’, $row_offset = 0, $limit = -1, $max = -1, $show_deleted = 0, $favorites = false, $singleSelect = false) in /home/shirtwor/public_html/crm/service/v4/SugarWebServiceUtilv4.php on line 555

Strict Standards: Declaration of SugarWebServiceImplv4::get_entries() should be compatible with SugarWebServiceImplv3_1::get_entries($session, $module_name, $ids, $select_fields, $link_name_to_fields_array, $track_view = false) in /home/shirtwor/public_html/crm/service/v4/SugarWebServiceImplv4.php on line 49[/i]

Can anyone help me to sort out the problem asap.

Thanks

Maybe you’re getting this problem:

https://github.com/salesagility/SuiteCRM/issues/3262

there’s a fix proposed for that, I believe.

(you probably upgraded your PHP on May 10th…)

Hi,

Thanks for your reply.

Yes, this is due to php upgrade on server.

I have tried with code in text file provided on link page but could not even login on SuiteCRM using that rest API code.

Can you please provide the rest api code to login on SuiteCRM.

Thanks,

Exactly what changes did you make, and where? We need to make sure you got it right…

Do you see any errors in your logs?

I don’t know anything about REST API, I was just trying to help with the other errors. If anybody else can help with the API, please feel free to join the discussion.

Hi,

I was using below code to login on SuiteCRM using rest api.

//========================================//
$url = ‘https://SERVER/PATH/service/v4/rest.php’;
// Open a curl session for making the call
$curl = curl_init($url);
// Tell curl to use HTTP POST
curl_setopt($curl, CURLOPT_POST, true);
// Tell curl not to return headers, but do return the response
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
// Set the POST arguments to pass to the Sugar server
$parameters = array(
‘user_auth’ => array(
‘user_name’ =>$username,
‘password’ => md5($password),
),
);
$json = json_encode($parameters);
$postArgs = array(
‘method’ => ‘login’,
‘input_type’ => ‘JSON’,
‘response_type’ => ‘JSON’,
‘rest_data’ => $json,
);
curl_setopt($curl, CURLOPT_POSTFIELDS, $postArgs);
// Make the REST call, returning the result
$response = curl_exec($curl);
// Convert the result from JSON format to a PHP array
$result = json_decode($response);

if ( is_object($result) and isset($result->id) ) {
echo $session = $result->id;
}
//========================================//

Can anyone let me know what changes should I make in this code to work with upgraded PHP.

Thanks,

The answer is in your logs, we need to know what error PHP is now throwing, to find out how to fix it…

Error log is creating below errors when I try for login on SuiteCRM using REST API:

[17-May-2017 12:52:04 UTC] PHP Strict Standards: Declaration of SugarWebServiceUtilv4::get_data_list() should be compatible with SugarWebServiceUtilv3_1::get_data_list($seed, $order_by = ‘’, $where = ‘’, $row_offset = 0, $limit = -1, $max = -1, $show_deleted = 0, $favorites = false, $singleSelect = false) in /home/shirtwor/public_html/crm/service/v4/SugarWebServiceUtilv4.php on line 555
[17-May-2017 12:52:04 UTC] PHP Strict Standards: Declaration of SugarWebServiceImplv4::get_entries() should be compatible with SugarWebServiceImplv3_1::get_entries($session, $module_name, $ids, $select_fields, $link_name_to_fields_array, $track_view = false) in /home/shirtwor/public_html/crm/service/v4/SugarWebServiceImplv4.php on line 49
[17-May-2017 12:52:04 UTC] PHP Warning: Missing argument 2 for SugarWebServiceImplv4::login() in /home/shirtwor/public_html/crm/service/v4/SugarWebServiceImplv4.php on line 70
[17-May-2017 12:52:04 UTC] PHP Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /home/shirtwor/public_html/crm/service/v4/SugarWebServiceUtilv4.php:555) in /home/shirtwor/public_html/crm/service/v4/SugarWebServiceImplv4.php on line 149
[17-May-2017 12:52:04 UTC] PHP Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/shirtwor/public_html/crm/service/v4/SugarWebServiceUtilv4.php:555) in /home/shirtwor/public_html/crm/service/v4/SugarWebServiceImplv4.php on line 149
[17-May-2017 12:52:04 UTC] PHP Warning: Cannot modify header information - headers already sent by (output started at /home/shirtwor/public_html/crm/service/v4/SugarWebServiceUtilv4.php:555) in /home/shirtwor/public_html/crm/service/core/REST/SugarRestJSON.php on line 59

You’re still getting the same errors, I’m not sure you applied the fixes correctly. The changes you need to make are these:

https://github.com/jobst/SuiteCRM/pull/1/files
https://github.com/salesagility/SuiteCRM/pull/3415/files

With these changes you should stop seeing the “strict standards” errors. If all goes well, that will also fix the API call. I didn’t try it, but the person who did those Pull Request says it works, so it’s worth trying…

Hi,

Thanks for your support.

I found the solution on an another thread which is below :

//=========================================//
ini_set(‘display_errors’, ‘0’);
error_reporting(E_ALL ^ E_STRICT);

crm.globe2.net/service/v4_1/SugarWebServiceUtilv4_1.php
crm.globe2.net/service/v4/SugarWebServiceUtilv4.php
crm.globe2.net/service/v3_1/SugarWebServiceUtilv3_1.php
crm.globe2.net/service/v3/SugarWebServiceUtilv3.php

If that doesnt solve it, add it here
crm.globe2.net/service/v4_1/rest.php

//=========================================//

After applying these changes, it is not creating the above errors and returning with login session id successfully.

let me check everything with this. I will share with you if still needed.

Thanks,