метод REST
scope: catalog
catalog.product.service.get
Получить значения полей услуги
Описание
Метод возвращает значения полей услуги по идентификатору.
Параметры
id
catalog_product_service.id
обязательный
Идентификатор услуги.
Для получения идентификаторов услуг необходимо использовать catalog.product.service.list
Примеры запроса
curl -X POST \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{"id":1265}' \
https://**put_your_bitrix24_address**/rest/**put_your_user_id_here**/**put_your_webhook_here**/catalog.product.service.get
curl -X POST \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{"id":1265,"auth":"**put_access_token_here**"}' \
https://**put_your_bitrix24_address**/rest/catalog.product.service.get
// 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 GetServiceResult = {
service: {
id: number
name: string
active: string
available: string
bundle: string
code: string
createdBy: number
dateActiveFrom: ISODate | null
dateActiveTo: ISODate | null
dateCreate: ISODate | null
detailPicture: { id: string; url: string; urlMachine: string } | null
detailText: string | null
detailTextType: string
iblockId: number
iblockSectionId: number | null
modifiedBy: number
previewPicture: { id: string; url: string; urlMachine: string } | null
previewText: string | null
previewTextType: string
sort: number
timestampX: ISODate | null
type: number
vatId: number | null
vatIncluded: string
xmlId: string | null
}
}
try {
const response = await $b24.actions.v2.call.make<GetServiceResult>({
method: 'catalog.product.service.get',
params: {
id: 1265,
},
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('Service:', result.service.id, result.service.name, result.service.active)
}
} catch (error) {
// Thrown on transport or SDK failures (AjaxError, SdkError, etc.)
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 getService() {
try {
// Initialize the SDK inside a Bitrix24 frame
const $b24 = await B24Js.initializeB24Frame()
const response = await $b24.actions.v2.call.make({
method: 'catalog.product.service.get',
params: {
id: 1265,
},
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('Service:', result.service.id, result.service.name, result.service.active)
} catch (error) {
// Thrown on transport or SDK failures (AjaxError, SdkError, etc.)
console.error(error)
}
}
document.addEventListener('DOMContentLoaded', getService)
</script>
from b24pysdk.errors import BitrixAPIError, BitrixSDKException
try:
bitrix_response = client.catalog.product.service.get(
bitrix_id=1265,
).response
result = bitrix_response.result
print(result)
except BitrixAPIError as error:
print(
"Ошибка Bitrix API",
f"error: {error.error}",
f"error_description: {error.error_description}",
sep="\n",
)
except BitrixSDKException as error:
print(f"Ошибка Bitrix SDK: {error.message}")
except Exception as error:
print(f"Непредвиденная ошибка: {error}")
try {
$response = $b24Service
->core
->call(
'catalog.product.service.get',
[
'id' => 1265
]
);
$result = $response
->getResponseData()
->getResult();
echo 'Success: ' . print_r($result, true);
// Нужная вам логика обработки данных
processData($result);
} catch (Throwable $e) {
error_log($e->getMessage());
echo 'Error getting product service: ' . $e->getMessage();
}
BX24.callMethod(
'catalog.product.service.get', {
id: 1265
},
function(result) {
if (result.error()) {
console.error(result.error());
} else {
console.info(result.data());
}
}
);
require_once('crest.php');
$result = CRest::call(
'catalog.product.service.get',
[
'id' => 1265
]
);
echo '<PRE>';
print_r($result);
echo '</PRE>';
// client и ctx уже созданы — см. раздел «SDK для Go»
res, err := client.Core().Call(ctx, "catalog.product.service.get", b24.Params{
"id": 1265,
}, b24.WithIdempotent())
if err != nil {
return fmt.Errorf("catalog.product.service.get: %w", err)
}
// Метод заворачивает ответ в объект с ключом "service".
raw, ok := b24.Unwrap(res.Result, "service")
if !ok {
return fmt.Errorf("в ответе нет ключа service")
}
var item struct {
Active string `json:"active"`
Available string `json:"available"`
Bundle string `json:"bundle"`
Code string `json:"code"`
CreatedBy int `json:"createdBy"`
DateActiveFrom string `json:"dateActiveFrom"`
}
if err := json.Unmarshal(raw, &item); err != nil {
return fmt.Errorf("разбор ответа: %w", err)
}
fmt.Println(item.Active, item.Available)
Ответ
HTTP-статус: 200
{
"result": {
"service": {
"active": "Y",
"available": "N",
"bundle": "N",
"code": "service",
"createdBy": 1,
"dateActiveFrom": "2024-05-28T10:00:00+03:00",
"dateActiveTo": "2024-05-29T10:00:00+03:00",
"dateCreate": "2024-05-27T10:00:00+03:00",
"detailPicture": {
"id": "6497",
"url": "\/rest\/catalog.product.download?fields%5BfieldName%5D=detailPicture\u0026fields%5BfileId%5D=6497\u0026fields%5BproductId%5D=1265",
"urlMachine": "\/rest\/catalog.product.download?fields%5BfieldName%5D=detailPicture\u0026fields%5BfileId%5D=6497\u0026fields%5BproductId%5D=1265"
},
"detailText": null,
"detailTextType": "text",
"iblockId": 23,
"iblockSectionId": 47,
"id": 1265,
"modifiedBy": 1,
"name": "Услуга",
"previewPicture": {
"id": "6496",
"url": "\/rest\/catalog.product.download?fields%5BfieldName%5D=previewPicture\u0026fields%5BfileId%5D=6496\u0026fields%5BproductId%5D=1265",
"urlMachine": "\/rest\/catalog.product.download?fields%5BfieldName%5D=previewPicture\u0026fields%5BfileId%5D=6496\u0026fields%5BproductId%5D=1265"
},
"previewText": null,
"previewTextType": "text",
"property258": {
"value": "test",
"valueId": "9809"
},
"property259": [
{
"value": "test1",
"valueId": "9810"
},
{
"value": "test2",
"valueId": "9811"
}
],
"sort": 100,
"timestampX": "2024-06-14T11:59:04+03:00",
"type": 7,
"vatId": 1,
"vatIncluded": "Y",
"xmlId": "1265"
}
},
"time": {
"start": 1718363239.355821,
"finish": 1718363240.027938,
"duration": 0.6721169948577881,
"processing": 0.2661628723144531,
"date_start": "2024-06-14T14:07:19+03:00",
"date_finish": "2024-06-14T14:07:20+03:00"
}
}
Возвращаемые данные
result
object
Корневой элемент ответа
service
catalog_product_service
Объект с информацией об услуге
time
time
Информация о времени выполнения запроса
Обработка ошибок
HTTP-статус: 400
{
"error":200040300010,
"error_description":"Access Denied"
}
| Код | Описание | Значение |
|---|---|---|
200040300000 |
Информационный блок с указанным идентификатором не существует | |
200040300040 |
Недостаточно прав для чтения элемента информационного блока | |
200040300010 |
Недостаточно прав для чтения торгового каталога | |
100 |
Не указан параметр id |
|
0 |
Услуга не существует | |
0 |
Другие ошибки (например, фатальные ошибки) |

