V
V
Vitaly Mironov2019-01-30 17:55:22
API
Vitaly Mironov, 2019-01-30 17:55:22

How to send form data to Amo Crm using api v2?

Old code that works but adds to the funnel - 'Not parsed' (api v1):

php code
$data['request']['unsorted'] = array(
  'category' => 'forms',
  'add' => array (
    array(
      'source' => $frome,
      'source_uid' => NULL,
      'data' => array(
        'leads' => array(
          array(
            'price' => $price,
            'date_create' => time(),
            'name' => $tema,
            'tags' => 'sdmall',
            'notes' => array(
              array(
                'text' => $comments,
                'note_type' => 4,
                'element_type' => 2,
              ),
            ),
          ),
        ),
        'contacts' => array(
            array(
              'name'=> $name,
              'custom_fields'=>array(
          
              )
            )
        ),
        'companies' => array(),
      ),
    
      'source_data' => array(
        'data' => array(
          'name_1' => array(
            'type' => 'text',
            'id' => 'name',
            'element_type' => '1',
            'name' => 'Имя',
            'value' => $name,
          ),
          '1708122_1' => array(
            'type' => 'multitext',
            'id' => '1708122',
            'element_type' => '1',
            'name' => 'Телефон',
            'value' => array(
              $phone
            ),
          ),
          '1708124_1' => array(
            'type' => 'multitext',
            'id' => '1708124',
            'element_type' => '1',
            'name' => 'Email',
            'value' => array(
              $email
            ),
          )
        ),
        'form_id' => 318,
        'form_type' => 1,
        'origin' => array(
          'ip' => $ip,
          'datetime' => 'Tue Nov 03 2015 13:02:24 GMT+0300 (Russia Standard Time)',
          'referer' => '',
        ),
        'date' => time(),
        'from' => $frome,
        'form_name' => $tema,
      ),
    ),
  ),
);
$link='https://'.$subdomain.'.amocrm.ru/api/unsorted/add/?api_key='.$user['USER_HASH'].'&login='.$user['USER_LOGIN'];


New code that comes to the desired funnel, but without form data (api v2):
php code
leads['request']['leads']['add']=array(
  array(
    'price' => $price,
    'date_create' => time(),
    'name' => $tema,
    'status_id' => 22185907,
    'tags' => 'sdmall',
    'notes' => array(
      array(
        'text' => $comments,
        'note_type' => 4,
        'element_type' => 2,
      ),
    'custom_fields'=>array(
        array(
            'id'=>1708122,
            'values'=>array(
                array(
                    'value'=>$phone,
                    'enum'=>'Телефон',
                )
            )
        ),
      )
    )
  )
);


Logs:
5c51ba7795949449621254.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Anokhin, 2019-01-31
@nor1m

it seems that in enum you need to pass a digital value according to the type of phone number, maybe that's why it doesn't work

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question