I am working on the bitrix24 REST API. I am able to get the 200 response from other API like crm.contact.add, crm.deal.add. When I am using the crm.contact.userfield.add It gives the error of "The custom type is invalid". Hence I need to know what to change in the API. I have changed the fields[FIELD_NAME] values and tried. But it gives the same error.
The purpose of this API is to add the additional custom fields to the CRM.
I tried with python's Bitrix24 module and getting the same error.
URL: https://b24-fnhdps.bitrix24.com/rest/crm.contact.userfield.add/?
fields[USER_TYPE_ID]=93&fields[FIELD_NAME]=Customer&fields[SETTINGS][DEFAULT_VALUE]=Dominion
&auth={auth}.
I am getting below error.
{
"error": "ERROR_CORE",
"error_description": "The custom type is invalid.<br>"
}.
Source: https://training.bitrix24.com/rest_help/crm/contacts/crm_contact_userfield_add.php
Please help me to sort out. Thanks in advance.
I found the issues. In the REST API, there is a parameter field[USER_TYPE_ID]. What I was passing is the ID of the CRM Contact. Actually, that should be the type of field. Hence the value of field[USER_TYPE_ID] is just string. Below is the working API.
URL: https://b24-fnhdps.bitrix24.com/rest/crm.contact.userfield.add/?
fields[USER_TYPE_ID]=string&fields[FIELD_NAME]=Customer&fields[SETTINGS][DEFAULT_VALUE]=Dominion
&auth={auth}.