S
S
SteepNET2020-10-02 16:56:18
RESTful API
SteepNET, 2020-10-02 16:56:18

Crest get list of leads?

Good afternoon! It was necessary to receive a list of leads without authorization according to the conditions, I decided to use https://github.com/bitrix-tools/crest
It turned out something like this

<?
require_once('src/crest.php');

$result = CRest::call(
    'crm.lead.list',
    [
        'filter' => [
            '>=DATE_CREATE' => '2020-07-01T00:00:00',
            '<=DATE_CREATE' => '2020-08-31T23:59:59',
        ],
        'select' => [
            'ID',
            'DATE_CREATE',
            'TITLE',
            'NAME',
            'PHONE',
            'SOURCE_ID',
            'CREATED_BY_ID',
            'STATUS_DESCRIPTION',
            'COMMENTS'
        ]
    ]
);
echo '<PRE>';
print_r ($result);
echo '</PRE>';



The list of leads is displayed, but I can’t get the next 50 leads, according to the method you need to call something like rest.php?start=50 but nothing comes out, it displays the same list. an ideal case to get a csv file right away...

Can someone help with this?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Andrey Nikolaev, 2020-10-08
@SteepNET

For the page, try this:

$result = CRest::call(
    'crm.lead.list',
    [
        'filter' => [
            ...
        ],
        'select' => [
            ...
        ],
        'start' => 50
    ]
);

Ideally, it would be generally displayed not in portions, but in given numbers

The maximum number of elements in list methods is 50, it can be less (see limit-key), but no more.
and even more ideal case to receive immediately csv file

This is only possible through the web interface.

I
Ilya Tsarenkov, 2021-10-26
@ILX

I had a similar problem when I got the company to do everything through a batch request.
In the place of crm.company.list , you substitute what you have more than 50 results and request page by page through batch

$result = CRest::call('batch',
            array(
                'halt' => 0,
                'cmd'=> array(
                'list_0' => 'crm.company.list',
                'list_1' =>'crm.company.list?start=50',
                'list_2' =>'crm.company.list?start=100',
                      )
               )
          );

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question