API interface to SugarCRM

Dear community,

I'm about to program an API interface to update my CRM data. The data for the SUGAR lies in an external database (Oracle). The Json-call is programmed and executed in the database with PL/SQL. So far we have updated the data from DB to DB, but we want to get away from that.

I'm using the "bulk"-entry point and update with every call 30 records. In a process with 1100 records (15 fields on each record) are updated. Now it could happen that single calls (begin, middle or at the end of the process) produces server errors 500, which write the following messages in the php log:

[01-Jul-2019 07:54:00 UTC] PHP Fatal error: Out of memory (allocated 765460480) (tried to allocate 4096 bytes) in D:\www\crm\include\SugarLogger\LoggerManager.php on line 0
01-Jul-2019 07:54:16 UTC] PHP Fatal error: Out of memory (allocated 390070272) (tried to allocate 4096 bytes) in D:\www\crm\data\SugarBean.php on line 600
01-Jul-2019 07:54:28 UTC] PHP Fatal error: Out of memory (allocated 203423744) (tried to allocate 12288 bytes) in D:\www\crm\data\BeanFactory.php on line 249

These data will not be transferred to SUGAR. The SUGAR-log is empty.

The issue doesn't happen each time.

We're running our CRM (Version 8.0.3) on Windows with an IIS as web server. Database is Oracle. SUGAR-CRM is the only application on that server. Oracle is hosted on a separate Unix-Server in the same environment. The settings in PHP.ini are already very high (memory, max_upload etc. ).

Are there settings (PHP, SUGAR or IIS) to avoid such errors? Ore what i am doing wrong. I've read that people sync a lot more data this way, as we request it.

Please feel free to ask more information about the PL/SQL programm or the PHP-Ini

A hint would very appreciated. Thank you for your efforts. 


Rene

  • Can you kindly provide output of phpinfo()?

    It seems either server memory  or php memory is not the enough.

    Regards

    André Lopes
    Lampada Global
    Skype: andre.lampada
  • Hi André,

    Many thanks for your quick response.

    Please find the php-Info as a PDF under the following link phpinfo.pdf

    Beste regards
    Rene

  • Hi Rene,

    I am not pretty much sure about this but I have faced a scenario like that. In your bulk entry point when you send the data for updation it depends that you are sending data either by urldecode(http_build_query($data)) or by json_encode($data) method.

    In the first method we received it in sugar by global variable $_POST and there is always a limit on this variable . So sometimes complete data will not get. 

    In second method which is better because there is no limit restriction we can get the data like this:

    require_once('include/upload_file.php');

     $file = new UploadFile();
    $file->temp_file_location = "php://input";
    $data = json_decode($file->get_file_contents(), true);

    Further I see the phpinfo() file which you share and in this I found that max_execution_time and post_max_size values are less as compare to my phpinfo file.

  • Hi Maryam,

    Thank you very much for your inputs. I'll check the possibility to create a file load with a logic hook (i didn't know this approach until now). Maybe it could really be an option instead of the REST API. But actually, I prefer the API way.

    What values did you set for these settings? I think we're already very high.
    max_execution_time = 21600
    post_max_size = 180M

    Thank you again
    Best regards
    Rene

  • Hi Rene,

    The approach which I discussed is used by calling an endpoint through curl request like:

    $data = json_encode($result_array);
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, '<sugar_url>/index.php?entryPoint=myCustomDataMigrate');
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));

    $response = curl_exec($ch);

    And my sugar file is:

    ./custom/myCustomDataMigrate.php have following code:

    require_once('include/upload_file.php');
    $file = new UploadFile();
    $file->temp_file_location = "php://input";
    $data = json_decode($file->get_file_contents(), true);

    The post_max_size value is 800M.