Announcement

Collapse
No announcement yet.

Can't create entity with REST API

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Can't create entity with REST API

    Hello! I Can't create RealEstateProperty entity with fields by REST. Here is my CURL code. Entity was created, but with defult values in fields:
    if($curl = curl_init() ) {
    curl_setopt($curl, CURLOPT_URL, $url);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($curl, CURLOPT_POST, true);
    $arParams = '{
    "name": "Test",
    "assignedUserId": "578c7227e8feef2a5"
    }';
    curl_setopt($curl, CURLOPT_POSTFIELDS, $arParams);
    curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
    $answer = curl_exec($curl);

    In logfile after creating i can see:

    [2016-07-18 10:41:15] Espo.WARNING: E_WARNING: Invalid argument supplied for foreach() {"code":2,"message":"Invalid argument supplied for foreach()","file":"/var/www/admin/www/SOME_SITE.ru/application/Espo/Services/Record.php","line":471} []
    [2016-07-18 10:41:15] Espo.ERROR: E_RECOVERABLE_ERROR: Argument 2 passed to Espo\Services\Record::beforeCreate() must be of the type array, string given, called in /var/www/admin/www/SOME_SITE.ru/application/Espo/Services/Record.php on line 523 and defined {"code":4096,"message":"Argument 2 passed to Espo\\Services\\Record::beforeCreate() must be of the type array, string given, called in /var/www/admin/www/SOME_SITE.ru/application/Espo/Services/Record.php on line 523 and defined","file":"/var/www/admin/www/SOME_SITE.ru/application/Espo/Services/Record.php","line":597} []
    [2016-07-18 10:41:15] Espo.ERROR: E_RECOVERABLE_ERROR: Argument 2 passed to Espo\Services\Record::afterCreate() must be of the type array, string given, called in /var/www/admin/www/SOME_SITE.ru/application/Espo/Services/Record.php on line 536 and defined {"code":4096,"message":"Argument 2 passed to Espo\\Services\\Record::afterCreate() must be of the type array, string given, called in /var/www/admin/www/SOME_SITE.ru/application/Espo/Services/Record.php on line 536 and defined","file":"/var/www/admin/www/SOME_SITE.ru/application/Espo/Services/Record.php","line":601} []

    Name is default and AssignedUser is NULL
    Last edited by Cebureque; 07-18-2016, 10:50 AM.

  • #2

    I guess you need to specify content type application/json and content length in header.

    Comment

    Working...
    X