метод REST
scope: sale
sale.propertygroup.add
Создать группу свойств
Описание
Метод sale.propertygroup.add создает группу свойств.
Параметры
fields
object
обязательный
Значения полей для создания группы свойств
Параметр fields
personTypeId
sale_person_type.id
обязательный
Идентификатор типа плательщика
name
string
обязательный
Название группы свойств
sort
integer
необязательный
Сортировка
Примеры запроса
curl -X POST \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{"fields":{"personTypeId":3,"name":"Новая группа свойств","sort":100}}' \
https://**put_your_bitrix24_address**/rest/**put_your_user_id_here**/**put_your_webhook_here**/sale.propertygroup.add
curl -X POST \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{"fields":{"personTypeId":3,"name":"Новая группа свойств","sort":100},"auth":"**put_access_token_here**"}' \
https://**put_your_bitrix24_address**/rest/sale.propertygroup.add
// 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 } from '@bitrix24/b24jssdk'
declare const $b24: B24Frame
// Shape of the payload returned in result (match the "response handling" section of the page)
type PropertyGroupAddResult = {
propertyGroup: {
id: number
name: string
personTypeId: number
sort: number
}
}
try {
const response = await $b24.actions.v2.call.make<PropertyGroupAddResult>({
method: 'sale.propertygroup.add',
params: {
fields: {
personTypeId: 3,
name: 'New property group',
sort: 100,
},
},
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(result.propertyGroup)
}
} 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 addPropertyGroup() {
try {
// Initialize the SDK inside a Bitrix24 frame
const $b24 = await B24Js.initializeB24Frame()
const response = await $b24.actions.v2.call.make({
method: 'sale.propertygroup.add',
params: {
fields: {
personTypeId: 3,
name: 'New property group',
sort: 100,
},
},
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(result.propertyGroup)
} catch (error) {
// Thrown on transport or SDK failures (AjaxError, SdkError, etc.)
console.error(error)
}
}
document.addEventListener('DOMContentLoaded', addPropertyGroup)
</script>
from b24pysdk.errors import BitrixAPIError, BitrixSDKException
fields = {
"personTypeId": 3,
"name": "Новая группа свойств",
"sort": 100,
}
try:
bitrix_response = client.sale.propertygroup.add(
fields=fields,
).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(
'sale.propertygroup.add',
[
'fields' => [
'personTypeId' => 3,
'name' => 'Новая группа свойств',
'sort' => 100,
],
]
);
$result = $response
->getResponseData()
->getResult();
echo 'Success: ' . print_r($result, true);
// Нужная вам логика обработки данных
processData($result);
} catch (Throwable $e) {
error_log($e->getMessage());
echo 'Error adding property group: ' . $e->getMessage();
}
BX24.callMethod(
"sale.propertygroup.add", {
"fields": {
"personTypeId": 3,
"name": "Новая группа свойств",
"sort": 100,
}
},
function(result) {
if (result.error()) {
console.error(result.error());
} else {
console.info(result.data());
}
}
);
require_once('crest.php');
$result = CRest::call(
'sale.propertygroup.add',
[
'fields' => [
'personTypeId' => 3,
'name' => 'Новая группа свойств',
'sort' => 100,
]
]
);
echo '<PRE>';
print_r($result);
echo '</PRE>';
// client и ctx уже созданы — см. раздел «SDK для Go»
res, err := client.Core().Call(ctx, "sale.propertygroup.add", b24.Params{
"fields": b24.Params{
"personTypeId": 3,
"name": "Новая группа свойств",
"sort": 100,
},
})
if err != nil {
return fmt.Errorf("sale.propertygroup.add: %w", err)
}
// Метод заворачивает ответ в объект с ключом "propertyGroup".
raw, ok := b24.Unwrap(res.Result, "propertyGroup")
if !ok {
return fmt.Errorf("в ответе нет ключа propertyGroup")
}
var item struct {
ID b24.ID `json:"id"`
Name string `json:"name"`
PersonTypeID b24.ID `json:"personTypeId"`
Sort int `json:"sort"`
}
if err := json.Unmarshal(raw, &item); err != nil {
return fmt.Errorf("разбор ответа: %w", err)
}
fmt.Println(item.ID, item.Name)
Ответ
HTTP-статус: 200
{
"result":{
"propertyGroup":{
"id":16,
"name":"Новая группа свойств",
"personTypeId":3,
"sort":100
}
},
"time":{
"start":1711451989.729911,
"finish":1711451989.907491,
"duration":0.1775798797607422,
"processing":0.008534908294677734,
"date_start":"2024-03-26T14:19:49+03:00",
"date_finish":"2024-03-26T14:19:49+03:00"
}
}
Возвращаемые данные
result
object
Корневой элемент ответа
propertyGroup
sale_order_property_group
Объект с информацией о добавленной группе свойств
time
time
Информация о времени выполнения запроса
Обработка ошибок
HTTP-статус: 400
{
"error":0,
"error_description":"Required fields: name"
}
| Код | Описание | Значение |
|---|---|---|
200950000006 |
Передано пустое значение одного из обязательных полей | |
200040300020 |
Недостаточно прав для добавления группы свойств | |
100 |
Не указан или пустой параметр fields |
|
0 |
Не переданы обязательные поля | |
0 |
Другие ошибки (например, фатальные ошибки) |

