Skip to content

Latest commit

 

History

History
307 lines (250 loc) · 8.76 KB

File metadata and controls

307 lines (250 loc) · 8.76 KB

Get File Version disk.version.get

{% note tip "" %}

If you are developing integrations for Bitrix24 using AI tools (Codex, Claude Code, Cursor), connect to the MCP server so that the assistant can utilize the official REST documentation.

{% endnote %}

Scope: disk

Who can execute the method: a user with "Read" access permission for the required file

The method disk.version.get returns the version of a file.

Method Parameters

{% include Note on required parameters %}

#| || Name type | Description || || id* integer | Identifier of the file version.

The identifier can be obtained using the method disk.file.getVersions || |#

Code Examples

{% include Note on examples %}

{% list tabs %}

  • cURL (Webhook)

    curl -X POST \
    -H "Content-Type: application/json" \
    -H "Accept: application/json" \
    -d '{"id":7169}' \
    https://**put_your_bitrix24_address**/rest/**put_your_user_id_here**/**put_your_webhook_here**/disk.version.get
  • cURL (OAuth)

    curl -X POST \
    -H "Content-Type: application/json" \
    -H "Accept: application/json" \
    -d '{"id":7169,"auth":"**put_access_token_here**"}' \
    https://**put_your_bitrix24_address**/rest/disk.version.get
  • JS (TS)

    // This snippet is an ES module: top-level await requires type="module" or a bundler.
    // $b24 is an already-initialized SDK instance (see the SDK "Get started" guide).
    import { Text } from '@bitrix24/b24jssdk'
    import type { B24Frame, ISODate } from '@bitrix24/b24jssdk'
    
    declare const $b24: B24Frame
    
    // Shape of the payload returned in result (match the "response handling" section of the page)
    type DiskVersionGetResult = {
      ID: string
      OBJECT_ID: string
      SIZE: string
      NAME: string
      GLOBAL_CONTENT_VERSION: string
      CREATE_TIME: ISODate
      CREATED_BY: string
      DOWNLOAD_URL: string
    }
    
    try {
      const response = await $b24.actions.v2.call.make<DiskVersionGetResult>({
        method: 'disk.version.get',
        params: {
          id: 7169,
        },
        requestId: Text.getUuidRfc4122()
      })
    
      // The payload is available only on a successful response
      if (!response.isSuccess) {
        console.error(response.getErrorMessages().join('; '))
      } else {
        const result = response.getData()!.result
        console.info('Version:', result.ID, 'File:', result.NAME, 'Size:', result.SIZE, 'Created:', result.CREATE_TIME)
      }
    } catch (error) {
      // Thrown on transport or SDK failures (AjaxError, SdkError, etc.)
      console.error(error)
    }
  • JS (UMD)

    <!-- Load the SDK (UMD build); it is exposed as the global B24Js -->
    <script src="https://unpkg.com/@bitrix24/b24jssdk@1/dist/umd/index.min.js"></script>
    <script>
      async function getVersion() {
        try {
          // Initialize the SDK inside a Bitrix24 frame
          const $b24 = await B24Js.initializeB24Frame()
    
          const response = await $b24.actions.v2.call.make({
            method: 'disk.version.get',
            params: {
              id: 7169,
            },
            requestId: B24Js.Text.getUuidRfc4122()
          })
    
          // The payload is available only on a successful response
          if (!response.isSuccess) {
            console.error(response.getErrorMessages().join('; '))
            return
          }
    
          const result = response.getData().result
          console.info('Version:', result.ID, 'File:', result.NAME, 'Size:', result.SIZE, 'Created:', result.CREATE_TIME)
        } catch (error) {
          // Thrown on transport or SDK failures (AjaxError, SdkError, etc.)
          console.error(error)
        }
      }
    
      document.addEventListener('DOMContentLoaded', getVersion)
    </script>
  • PHP

    try {
        $response = $b24Service
            ->core
            ->call(
                'disk.version.get',
                [
                    'id' => 7169
                ]
            );
    
        $result = $response
            ->getResponseData()
            ->getResult();
    
        echo 'Success: ' . print_r($result, true);
        processData($result);
    
    } catch (Throwable $e) {
        error_log($e->getMessage());
        echo 'Error fetching disk version: ' . $e->getMessage();
    }
  • BX24.js

    BX24.callMethod(
        'disk.version.get',
        {
            id: 7169
        },
        function (result) {
            if (result.error()) {
                console.error(result.error());
            } else {
                console.log(result.data());
            }
        }
    );
  • PHP CRest

    require_once('crest.php');
    
    $result = CRest::call(
        'disk.version.get',
        [
            'id' => 7169
        ]
    );
    
    echo '<PRE>';
    print_r($result);
    echo '</PRE>';
  • Go

    // client and ctx are already created — see the Go SDK section
    res, err := client.Core().Call(ctx, "disk.version.get", b24.Params{
    	"id": 7169,
    }, b24.WithIdempotent())
    if err != nil {
    	return fmt.Errorf("disk.version.get: %w", err)
    }
    
    var item struct {
    	ID                   b24.ID `json:"ID"`
    	ObjectID             b24.ID `json:"OBJECT_ID"`
    	Size                 string `json:"SIZE"`
    	Name                 string `json:"NAME"`
    	GlobalContentVersion string `json:"GLOBAL_CONTENT_VERSION"`
    	CreateTime           string `json:"CREATE_TIME"`
    }
    if err := json.Unmarshal(res.Result, &item); err != nil {
    	return fmt.Errorf("parse response: %w", err)
    }
    fmt.Println(item.ID, item.ObjectID)

{% endlist %}

Response Handling

HTTP status: 200

{
    "result": {
        "ID": "7169",
        "OBJECT_ID": "8903",
        "SIZE": "52486",
        "NAME": "Picture.png",
        "GLOBAL_CONTENT_VERSION": "1",
        "CREATE_TIME": "2025-12-23T10:30:01+01:00",
        "CREATED_BY": "1269",
        "DOWNLOAD_URL": "https://test.bitrix24.com/rest/download.json?auth=b79c4a690000071b006e2cf2000004f50000076312db694aabed7ccf9e3d4fd1b992e3&token=disk%7CaWQ9NzE2OSZzZXJ2aWNlPXZlcnNpb24mXz0xR2VaZDdER2RBZW1WbU8xc0swSGRxYzVBclhJU0pYcQ%3D%3D%7CImRvd25sb2FkfGRpc2t8YVdROU56RTJPU1p6WlhKMmFXTmxQWFpsY25OcGIyNG1YejB4UjJWYVpEZEVSMlJCWlcxV2JVOHhjMHN3U0dSeFl6VkJjbGhKVTBwWWNRPT18Yjc5YzRhNjkwMDAwMDcxYjAwNmUyY2YyMDAwMDA0ZjUwMDAwMDc2MzEyZGI2OTRhYWJlZDdjY2Y5ZTNkNGZkMWI5OTJlMyI%3D.MCpHhZb32NO7IClkN44tbm%2FkyPM%2F4ZJ1P2uaMEPo0As%3D"
    },
    "time": {
        "start": 1766496433,
        "finish": 1766496433.618999,
        "duration": 0.6189990043640137,
        "processing": 0,
        "date_start": "2025-12-23T14:27:13+01:00",
        "date_finish": "2025-12-23T14:27:13+01:00",
        "operating_reset_at": 1766497033,
        "operating": 0
    }
}

Returned Data

#| || Name type | Description || || result array | Array with version data || || ID integer | Identifier of the version || || OBJECT_ID integer | Identifier of the file to which the version belongs || || SIZE integer | Size of the version in bytes || || NAME string | Name of the file at the time the version was created || || GLOBAL_CONTENT_VERSION integer | Incremental version counter of the file || || CREATE_TIME string | Creation time of the version || || CREATED_BY integer | Identifier of the user who created the version || || DOWNLOAD_URL string | Link to download the version || || time time | Information about the request execution time || |#

Error Handling

HTTP status: 400

{
    "error":"ERROR_ARGUMENT",
    "error_description":"Invalid value of parameter `id`"
}

{% include notitle error handling %}

Possible Error Codes

#| || Code | Description | Value || || ERROR_ARGUMENT | Invalid value of parameter id | Parameter id is missing or has an invalid type || || ERROR_NOT_FOUND | Could not find entity with id X | Version with the specified id was not found || || ACCESS_DENIED | Access denied | Insufficient rights to read the file || |#

{% include system errors %}

Continue Learning