v1.3.0

CallV3.make

Method for making Bitrix24 REST API version 3 calls.

Overview

Use CallV3.make() to call REST API version 3 methods.

The method returns a Promise with an AjaxResult object containing response data, status, and error handling methods.

// Basic usage
const response = await $b24.actions.v3.call.make({
  method: 'tasks.task.get',
  params: {
    id: 123
  },
  requestId: 'unique-request-id'
})

Method Signature

make<T = unknown>(
  options: ActionCallV3
): Promise<AjaxResult<T>>

Parameters

The options object contains the following properties:

ParameterTypeRequiredDescription
methodstringYesREST API method name (e.g., tasks.task.get, tasks.task.add).
paramsTypeCallParamsNoObject with parameters to pass to the REST API method.
requestIdstringNoUnique request identifier for tracking. Used for request deduplication and debugging.

Return Value

Promise<AjaxResult<T>> — a promise that resolves to an AjaxResult object.

This object provides:

  • .getData(): SuccessPayload<T> | undefined — returns the success envelope { result: T, time: PayloadTime }, or undefined when the request failed. Check .isSuccess first.
  • .isSuccess: boolean — flag indicating successful request execution.
  • .getErrorMessages(): string[] — array of error messages.

Error Handling

The SDK does not keep a client-side list of v3 methods: CallV3.make() sends whatever method you pass to the v3 endpoint and the server decides. If the method is not a v3 method, the server replies with METHODNOTFOUNDEXCEPTION as a soft error (response.isSuccess === false, the message in getErrorMessages()) — there is no pre-flight SDK throw. Use CallV2.make() for legacy methods, or check apidocs.bitrix24.com (or the portal's own rest.documentation.openapi) for what exists in v3.

For successful requests, always check isSuccess and handle errors:

// @check-ignore: top-level return in error-handling illustration

const response = await $b24.actions.v3.call.make({
  method: 'some.method',
  params: { /* some_params */ },
  requestId: 'unique-request-id'
})

if (!response.isSuccess) {
  // Handling error
  console.error(new Error(`Error: ${response.getErrorMessages().join('; ')}`))
  return
}

// Working with a successful result
const data = response.getData()?.result

Examples

Getting a Task

import { B24Hook, LoggerFactory, SdkError, AjaxError } from '@bitrix24/b24jssdk'

type Task = {
  id: number
  title: string
  autocompleteSubTasks: boolean
}

const devMode = typeof import.meta !== 'undefined' && (import.meta?.dev || globalThis._importMeta_.env?.DEV)
const $logger = LoggerFactory.createForBrowser('Example:taskGet', devMode)
const $b24 = B24Hook.fromWebhookUrl('https://your_domain.bitrix24.com/rest/1/webhook_code/')

async function getTask(itemId: number, requestId: string): Promise<Task> {
  const response = await $b24.actions.v3.call.make<{ item: Task }>({
    method: 'tasks.task.get',
    params: {
      id: itemId,
      select: ['id', 'title', 'autocompleteSubTasks']
    },
    requestId
  })

  if (!response.isSuccess) {
    throw new SdkError({
      code: 'MY_APP_GET_PROBLEM',
      description: `Problem ${response.getErrorMessages().join('; ')}`,
      status: 404
    })
  }

  return (response.getData()!.result as { item: Task }).item
}

// Usage
const itemId = 2
const requestId = `task-${itemId}`
try {
  const entity = await getTask(itemId, requestId)
  $logger.info(`Entity [${entity.id}]`, { entity })
} catch (error) {
  if (error instanceof AjaxError) {
    $logger.critical(error.message, { requestId, code: error.code })
  } else {
    $logger.alert('Problem', { requestId, error })
  }
}

Long-Running Requests

Non-idempotent methods that create or persist state — for example tasks.task.add — can exceed the default 30-second axios timeout on a busy portal. On a timeout the SDK retries by default, which can create duplicate entities server-side (see issue #24).

For any method that creates or persists state, raise the axios timeout and disable retries on transport errors:

import { ApiVersion, ParamsFactory } from '@bitrix24/b24jssdk'

// const $b24 = ...
$b24.getHttpClient(ApiVersion.v3).ajaxClient.defaults.timeout = 120_000
await $b24.setRestrictionManagerParams({
  ...ParamsFactory.getDefault(),
  retryOnNetworkError: false
})

await $b24.actions.v3.call.make({
  method: 'tasks.task.add',
  params: {/*…*/}
})

See Limiters → Long-Running Requests & Non-idempotent Calls for the full explanation and alternative configurations.

Alternatives and Recommendations

  • For working with lists: Instead of manually managing pagination use:
    • CallList — automatically retrieves all pages and returns a single result.
    • FetchList — returns an async generator for step-by-step processing of large lists.
  • For batch operations: Use Batch to execute up to 50 commands in a single request.
  • On the client-side (browser): Use the built-in B24Frame object.