F
F
FinchRED2021-06-25 12:57:55
JavaScript
FinchRED, 2021-06-25 12:57:55

How to send a batch request to Bitrix in a convenient form on fetch api.?

The matter is that I can send normal object when I address to one method.
But if I do the same with butch, then the request is empty.
If for example , I will write this 'comp': 'crm.company.get?ID=1' as follows

'comp': {
          'crm.company.get':{
                               'ID'=1;
                                }


Is it possible to somehow do without a self-written POST request generator.
let limitF = document.querySelector('.limit').value;
    fetch("https://17iuna21.bitrix24.ru/rest/1/zuvojt2d1osnlurg/batch", {
        method: "POST",
        mode: 'cors',
        credentials: 'same-origin', 
        headers: new Headers(
            {
                Accept: 'application/json',
                'Content-Type': 'application/json'
            }),
        body: JSON.stringify(
            {
                'halt': 0,
                'cmd': {
                    'leads': `crm.lead.list?FILTER[>OPPORTUNITY]=${limitF}&SELECT[]=*&SELECT[]=UF_CRM_1624283873527`,
                    'Deal': `crm.deal.list?FILTER[>OPPORTUNITY]=${limitF}`,
                    'comp': 'crm.company.get?ID=1'
                }
            }),
        redirect: 'follow', 
        referrerPolicy: "no-referrer", // no-referrer, *client
    })

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question