Download Product Files catalog.product.download
Choose a tool for developing with an AI agent:
- use Alaio Vibecode to build an app for Bitrix24 from a task description without knowing any programming language. The agent writes the code and deploys the app to a server, with no manual hosting setup
- use the MCP server to develop a REST API integration in your own project. The agent refers to the official REST documentation
Scope:
catalogWho can execute the method: a user with the "View product catalog", "View catalog products", or "Edit selling price" permission and permission to read the product in the information block
The catalog.product.download method downloads product files from the trade catalog using the provided parameters.
Method Parameters
Required parameters are marked with *
|
Name |
Description |
|
fields* |
Parameters of the file to download. Field description |
Parameter fields
|
Name |
Description |
|
fileId* |
Identifier of the file. The identifier is returned by the catalog.product.get and catalog.product.list methods in the |
|
productId* |
Identifier of the product. You can retrieve product identifiers using the catalog.product.list method |
|
fieldName* |
Product field where the file is stored:
In catalog.product.get and catalog.product.list responses, the You can retrieve property identifiers using the catalog.productProperty.list method |
Code Examples
The examples use direct HTTP requests to save the binary response.
How to Use Examples in Documentation
curl --fail -X POST \
-H "Content-Type: application/json" \
-d '{"fields":{"fileId":6439,"productId":1243,"fieldName":"detailPicture"}}' \
-o product-picture.png \
https://**put_your_bitrix24_address**/rest/**put_your_user_id_here**/**put_your_webhook_here**/catalog.product.download
curl --fail -X POST \
-H "Content-Type: application/json" \
-d '{"fields":{"fileId":6439,"productId":1243,"fieldName":"detailPicture"},"auth":"**put_access_token_here**"}' \
-o product-picture.png \
https://**put_your_bitrix24_address**/rest/catalog.product.download
// 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 type { B24Frame } from '@bitrix24/b24jssdk'
declare const $b24: B24Frame
try {
const auth = $b24.auth.getAuthData()
if (!auth) {
throw new Error('No auth data')
}
// The method returns a binary file, so the request is sent directly
const response = await fetch(`${$b24.getTargetOriginWithPath()}/catalog.product.download`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
fields: {
fileId: 6439,
productId: 1243,
fieldName: 'detailPicture',
},
auth: auth.access_token,
}),
})
if (!response.ok) {
const error = await response.json()
throw new Error(error.error_description)
}
const blob: Blob = await response.blob()
console.info('File size:', blob.size, 'type:', blob.type)
} catch (error) {
console.error(error)
}
<!-- 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 downloadProductFile() {
try {
// Initialize the SDK inside a Bitrix24 frame
const $b24 = await B24Js.initializeB24Frame()
const auth = $b24.auth.getAuthData()
if (!auth) {
throw new Error('No auth data')
}
// The method returns a binary file, so the request is sent directly
const response = await fetch(`${$b24.getTargetOriginWithPath()}/catalog.product.download`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
fields: {
fileId: 6439,
productId: 1243,
fieldName: 'detailPicture',
},
auth: auth.access_token,
}),
})
if (!response.ok) {
const error = await response.json()
throw new Error(error.error_description)
}
// Save the file in the browser
const blob = await response.blob()
const link = document.createElement('a')
link.href = URL.createObjectURL(blob)
link.download = 'product-picture.png'
link.click()
URL.revokeObjectURL(link.href)
} catch (error) {
console.error(error)
}
}
document.addEventListener('DOMContentLoaded', downloadProductFile)
</script>
import json
from urllib.error import HTTPError
from urllib.request import Request, urlopen
url = "https://**put_your_bitrix24_address**/rest/**put_your_user_id_here**/**put_your_webhook_here**/catalog.product.download"
payload = {
"fields": {
"fileId": 6439,
"productId": 1243,
"fieldName": "detailPicture",
}
}
request = Request(
url,
data=json.dumps(payload).encode("utf-8"),
headers={"Content-Type": "application/json"},
method="POST",
)
try:
with urlopen(request) as response, open("product-picture.png", "wb") as output:
output.write(response.read())
except HTTPError as error:
print("Bitrix API error:", json.loads(error.read()).get("error_description"))
<?php
$url = 'https://**put_your_bitrix24_address**/rest/**put_your_user_id_here**/**put_your_webhook_here**/catalog.product.download';
$payload = json_encode([
'fields' => [
'fileId' => 6439,
'productId' => 1243,
'fieldName' => 'detailPicture',
],
], JSON_THROW_ON_ERROR);
$request = curl_init($url);
curl_setopt_array($request, [
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $payload,
CURLOPT_HTTPHEADER => ['Content-Type: application/json'],
CURLOPT_RETURNTRANSFER => true,
]);
$file = curl_exec($request);
$status = curl_getinfo($request, CURLINFO_HTTP_CODE);
$error = curl_error($request);
curl_close($request);
if ($file === false || $status !== 200) {
throw new RuntimeException('Failed to download product file: HTTP ' . $status . ' ' . $error);
}
file_put_contents('product-picture.png', $file);
// The method returns a binary file, so the request is sent directly
const auth = BX24.getAuth();
fetch(`https://${auth.domain}/rest/catalog.product.download`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
fields: {
fileId: 6439,
productId: 1243,
fieldName: 'detailPicture'
},
auth: auth.access_token
})
})
.then(response => response.ok
? response.blob()
: response.json().then(error => { throw new Error(error.error_description); }))
.then(blob => {
const link = document.createElement('a');
link.href = URL.createObjectURL(blob);
link.download = 'product-picture.png';
link.click();
URL.revokeObjectURL(link.href);
})
.catch(error => console.error(error));
require_once('crest.php');
// CRest::call() decodes the response as JSON, so the binary file is requested directly.
// C_REST_WEB_HOOK_URL is set in settings.php
$request = curl_init(C_REST_WEB_HOOK_URL . 'catalog.product.download');
curl_setopt_array($request, [
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => http_build_query([
'fields' => [
'fileId' => 6439,
'productId' => 1243,
'fieldName' => 'detailPicture',
],
]),
CURLOPT_RETURNTRANSFER => true,
]);
$file = curl_exec($request);
$status = curl_getinfo($request, CURLINFO_HTTP_CODE);
curl_close($request);
if ($status === 200) {
file_put_contents('product-picture.png', $file);
} else {
echo '<PRE>';
print_r(json_decode($file, true));
echo '</PRE>';
}
// The method returns a binary file, so the request is sent directly
url := "https://**put_your_bitrix24_address**/rest/**put_your_user_id_here**/**put_your_webhook_here**/catalog.product.download"
body, err := json.Marshal(map[string]any{
"fields": map[string]any{
"fileId": 6439,
"productId": 1243,
"fieldName": "detailPicture",
},
})
if err != nil {
return err
}
resp, err := http.Post(url, "application/json", bytes.NewReader(body))
if err != nil {
return fmt.Errorf("catalog.product.download: %w", err)
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
var apiErr struct {
Error string `json:"error"`
ErrorDescription string `json:"error_description"`
}
_ = json.NewDecoder(resp.Body).Decode(&apiErr)
return fmt.Errorf("catalog.product.download: %s", apiErr.ErrorDescription)
}
file, err := os.Create("product-picture.png")
if err != nil {
return err
}
defer file.Close()
if _, err := io.Copy(file, resp.Body); err != nil {
return fmt.Errorf("save file: %w", err)
}
Response Handling
HTTP status: 200
The response contains the file content with the Content-Type and Content-Disposition headers, for example Content-Type: image/png and Content-Disposition: attachment; filename="logo.png". The method checks that fileId belongs to the specified product and fieldName. Save the response as a file: a successful call has no JSON result field.
Returned Data
The file content is returned, not a JSON result object. Retrieve the file ID and URL from detailPicture, previewPicture, or a file property in the catalog.product.get response.
Error Handling
HTTP status: 400
{
"error": "0",
"error_description": "Product file wrong"
}
|
Name |
Description |
|
error |
String error code. It consists of digits, Latin letters, and underscores. It may arrive empty — in that case only |
|
error_description |
Error message for the developer. Do not show it to the end user without processing |
Possible Error Codes
|
Status |
Code |
Description |
Cause |
|
|
|
|
The user has none of the "View product catalog", "View catalog products", or "Edit selling price" permissions |
|
|
|
|
The product's information block was not found |
|
|
|
|
No permission to read the product in the information block |
|
|
Empty value |
|
No product exists with the specified |
|
|
|
|
The |
|
|
|
|
Required fields were not provided. The description lists only the missing fields |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
The file record was not found |
Statuses and System Error Codes
HTTP Status: 4xx, 5xx
The errors described below are returned by the REST API itself, not by the logic of a specific method. They can arrive in response to any method.
|
Status |
Code |
Description |
|
|
|
An internal server error has occurred. Retry the call, and if the error persists, contact the server administrator or Bitrix24 technical support |
|
|
|
The server returned an unexpected response. Retry the call, and if the error persists, contact the server administrator or Bitrix24 technical support |
|
|
|
The request intensity limit has been exceeded |
|
|
|
The method is blocked because the request resource intensity limit has been exceeded. The block is lifted automatically once the accumulated execution time of the method no longer exceeds the limit |
|
|
|
The request contains no authorization data: neither an access token nor a webhook code was passed |
|
|
|
Methods are called over the HTTPS protocol only |
|
|
|
The REST API is blocked due to overload. This is a manual individual block. To have it lifted, contact Bitrix24 technical support |
|
|
|
REST API access is not active for this account. In Bitrix24 Cloud, check the current plan or trial status: Vibe+ plans include REST API access, while Essentials plans do not. A webhook receives a different error message — |
|
|
|
No active webhook with the specified user identifier and secret code was found |
|
|
|
No method with this name was found. The name is misspelled, the method does not exist in the REST API, or it is unavailable without the required scope |
|
|
|
The request requires broader permissions than the token has: for a webhook these are the permissions granted to it, for an application it is the scope. For an application, the error message ends with |
|
|
|
The access token has expired |
|
|
|
The application is installed, but the Bitrix24 administrator has granted access to it only to specific users |
|
|
|
The public part of the site is closed. To open it on an on-premise installation, disable the "Temporary closure of the public part of the site" option. Path to the setting: Desktop > Settings > Product Settings > Module Settings > Main Module > Temporary closure of the public part of the site |