Download Product Variation Files catalog.product.offer.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: administrator
The method catalog.product.offer.download downloads a product variation file from an image field or a file property.
Method Parameters
Required parameters are marked with *
|
Name |
Description |
|
fields* |
Product variation file parameters (detailed description) |
Parameter fields
Required parameters are marked with *
|
Name |
Description |
|
fileId* |
Identifier of the registered file. Use the |
|
productId* |
Identifier of the product variation. To obtain the identifiers of product variations, you need to use catalog.product.offer.list |
|
fieldName* |
Name of the field where the file is stored. Pass the name in camelCase, in the same format returned by catalog.product.offer.get and catalog.product.offer.list. Possible values:
You can obtain product variation property identifiers and symbolic codes using catalog.productProperty.list. Only file-type properties can be downloaded |
Code Examples
How to Use Examples in Documentation
The method returns the file contents, not JSON. Send a direct HTTP request and save the body of a successful response as a file.
curl -X POST \
-H "Content-Type: application/json" \
-d '{"fields":{"fileId":6538,"productId":1286,"fieldName":"detailPicture"}}' \
--output offer-file \
https://**put_your_bitrix24_address**/rest/**put_your_user_id_here**/**put_your_webhook_here**/catalog.product.offer.download
curl -X POST \
-H "Content-Type: application/json" \
-d '{"fields":{"fileId":6538,"productId":1286,"fieldName":"detailPicture"},"auth":"**put_access_token_here**"}' \
--output offer-file \
https://**put_your_bitrix24_address**/rest/catalog.product.offer.download
import { writeFile } from 'node:fs/promises'
const response = await fetch(
'https://**put_your_bitrix24_address**/rest/**put_your_user_id_here**/**put_your_webhook_here**/catalog.product.offer.download',
{
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
fields: {
fileId: 6538,
productId: 1286,
fieldName: 'detailPicture',
},
}),
},
)
if (!response.ok) {
throw new Error(await response.text())
}
const file = new Uint8Array(await response.arrayBuffer())
await writeFile('offer-file', file)
<script>
async function downloadOfferFile() {
const response = await fetch(
'https://**put_your_bitrix24_address**/rest/catalog.product.offer.download',
{
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
fields: {
fileId: 6538,
productId: 1286,
fieldName: 'detailPicture',
},
auth: '**put_access_token_here**',
}),
},
)
if (!response.ok) {
throw new Error(await response.text())
}
const blob = await response.blob()
const url = URL.createObjectURL(blob)
const link = document.createElement('a')
link.href = url
link.download = 'offer-file'
document.body.appendChild(link)
link.click()
link.remove()
URL.revokeObjectURL(url)
}
document.addEventListener('DOMContentLoaded', downloadOfferFile)
</script>
import requests
response = requests.post(
"https://**put_your_bitrix24_address**/rest/**put_your_user_id_here**/**put_your_webhook_here**/catalog.product.offer.download",
json={
"fields": {
"fileId": 6538,
"productId": 1286,
"fieldName": "detailPicture",
}
},
)
response.raise_for_status()
with open("offer-file", "wb") as file:
file.write(response.content)
$curl = curl_init('https://**put_your_bitrix24_address**/rest/**put_your_user_id_here**/**put_your_webhook_here**/catalog.product.offer.download');
curl_setopt_array($curl, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['Content-Type: application/json'],
CURLOPT_POSTFIELDS => json_encode([
'fields' => [
'fileId' => 6538,
'productId' => 1286,
'fieldName' => 'detailPicture',
],
]),
]);
$response = curl_exec($curl);
$httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
curl_close($curl);
if ($httpCode === 200) {
file_put_contents('offer-file', $response);
} else {
echo $response;
}
const auth = BX24.getAuth()
const url = new URL(`https://${auth.domain}/rest/catalog.product.offer.download`)
url.searchParams.set('auth', auth.access_token)
url.searchParams.set('fields[fileId]', 6538)
url.searchParams.set('fields[productId]', 1286)
url.searchParams.set('fields[fieldName]', 'detailPicture')
fetch(url)
.then(async response => {
if (!response.ok) {
throw new Error(await response.text())
}
return response.blob()
})
.then(blob => {
const objectUrl = URL.createObjectURL(blob)
const link = document.createElement('a')
link.href = objectUrl
link.download = 'offer-file'
document.body.appendChild(link)
link.click()
link.remove()
URL.revokeObjectURL(objectUrl)
})
.catch(error => console.error(error))
payload, err := json.Marshal(map[string]any{
"fields": map[string]any{
"fileId": 6538, "productId": 1286, "fieldName": "detailPicture",
},
})
if err != nil {
return err
}
url := "https://**put_your_bitrix24_address**/rest/**put_your_user_id_here**/**put_your_webhook_here**/catalog.product.offer.download"
response, err := http.Post(url, "application/json", bytes.NewReader(payload))
if err != nil {
return err
}
defer response.Body.Close()
body, err := io.ReadAll(response.Body)
if err != nil {
return err
}
if response.StatusCode != http.StatusOK {
return fmt.Errorf("download failed: %s", body)
}
return os.WriteFile("offer-file", body, 0o644)
Response Handling
HTTP status: 200
The response body contains the file contents. This is a binary response, not JSON: the Content-Type header depends on the file format, and Content-Disposition: attachment contains the download file name.
Returned Data
A file with the fileId identifier from the fieldName field of the productId variation.
Error Handling
HTTP status: 400
{
"error": "0",
"error_description": "Required fields: fileId"
}
|
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
|
Code |
error_description |
Description |
|
|
|
Insufficient permissions to read the product catalog |
|
Empty value |
|
The product variation with the specified |
|
|
|
The |
|
|
|
The |
|
|
|
The file with the specified |
|
|
|
One or more required parameters are missing. The message lists the missing parameters |
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 |
Continue Learning
- Add Product Variation catalog.product.offer.add
- Update Product Variation Fields catalog.product.offer.update
- Get Product Variation Field Values catalog.product.offer.get
- Get a list of product variations catalog.product.offer.list
- Delete Product Variation catalog.product.offer.delete
- Get Product Variation Fields by Filter catalog.product.offer.getFieldsByFilter