Update Currency crm.currency.update
Scope:
crmWho can execute the method: any user with access to modify CRM settings
This method updates an existing currency.
Parameters
|
Name |
Description |
|
ID |
Currency identifier. Corresponds to the ISO 4217 standard. The identifier can be obtained using the crm.currency.list method. |
|
fields |
Field values (detailed description provided below) for updating the currency in the following structure:
|
Parameter fields
Required parameters are marked with *
|
Name |
Description |
|
SORT |
Position in the currency list. Default value is |
|
AMOUNT_CNT* |
Denomination. Typically, |
|
AMOUNT* |
Exchange rate relative to the base currency. |
|
BASE |
Indicates whether the currency is a base currency. Possible values:
Default value is Warning It is not recommended to change the base currency via REST. Otherwise, you will need to change the rates of all currencies. |
|
LANG |
Currency localization parameters. An object in the format If not all languages are specified, the remaining ones will use default localization parameters. |
Parameter LANG
|
Name |
Description |
|
DECIMALS* |
Number of decimal places in the fractional part. |
|
DEC_POINT |
Decimal point for output. |
|
FORMAT_STRING |
Format template. |
|
FULL_NAME |
Name of the currency in the language for which localization is added. |
|
HIDE_ZERO |
Indicates whether to hide insignificant zeros. |
|
THOUSANDS_SEP |
Thousands separator. |
|
THOUSANDS_VARIANT |
Code for the thousands separator. Refer to the crm_currency_localization documentation for acceptable values. |
Examples
-
Changing the exchange rate of the yuan relative to the base currency.
How to Use Examples in Documentation
cURL (Webhook)cURL (OAuth)JSPHPcurl -X POST \ -H "Content-Type: application/json" \ -H "Accept: application/json" \ -d '{"ID":"CNY","fields":{"AMOUNT":15.3449}}' \ https://**put_your_bitrix24_address**/rest/**put_your_user_id_here**/**put_your_webhook_here**/crm.currency.updatecurl -X POST \ -H "Content-Type: application/json" \ -H "Accept: application/json" \ -d '{"ID":"CNY","fields":{"AMOUNT":15.3449},"auth":"**put_access_token_here**"}' \ https://**put_your_bitrix24_address**/rest/crm.currency.updateBX24.callMethod( "crm.currency.update", { ID: 'CNY', fields: { AMOUNT: 15.3449, } }, ) .then( function(result) { if (result.error()) { console.error(result.error()); } else { console.log(result); } }, function(error) { console.info(error); } );require_once('crest.php'); $result = CRest::call( 'crm.currency.update', [ 'ID' => 'CNY', 'fields' => [ 'AMOUNT' => 15.3449, ] ] ); echo '<PRE>'; print_r($result); echo '</PRE>'; -
Changing the localizations of the currency (using the example of the US dollar)
After executing this example, the localizations for the currency USD will be changed (or added) only for English and German languages. Localizations for other languages, if they existed, will not be changed.
This example is similar to the operation of the crm.currency.localizations.set method.
How to Use Examples in Documentation
cURL (Webhook)cURL (OAuth)JSPHPcurl -X POST \ -H "Content-Type: application/json" \ -H "Accept: application/json" \ -d '{"ID":"USD","fields":{"LANG":{"en":{"DECIMALS":2,"DEC_POINT":".","FORMAT_STRING":"$#","FULL_NAME":"US Dollar","HIDE_ZERO":"Y","THOUSANDS_VARIANT":"S"},"de":{"DECIMALS":2,"DEC_POINT":".","FORMAT_STRING":"# $","FULL_NAME":"US-Dollar","HIDE_ZERO":"Y","THOUSANDS_VARIANT":"C"}}}}' \ https://**put_your_bitrix24_address**/rest/**put_your_user_id_here**/**put_your_webhook_here**/crm.currency.updatecurl -X POST \ -H "Content-Type: application/json" \ -H "Accept: application/json" \ -d '{"ID":"USD","fields":{"LANG":{"en":{"DECIMALS":2,"DEC_POINT":".","FORMAT_STRING":"$#","FULL_NAME":"US Dollar","HIDE_ZERO":"Y","THOUSANDS_VARIANT":"S"},"de":{"DECIMALS":2,"DEC_POINT":".","FORMAT_STRING":"# $","FULL_NAME":"US-Dollar","HIDE_ZERO":"Y","THOUSANDS_VARIANT":"C"}}},"auth":"**put_access_token_here**"}' \ https://**put_your_bitrix24_address**/rest/crm.currency.updateBX24.callMethod( "crm.currency.update", { ID: 'USD', fields: { LANG: { en: { DECIMALS: 2, DEC_POINT: '.', FORMAT_STRING: '$#', FULL_NAME: 'US Dollar', HIDE_ZERO: 'Y', THOUSANDS_VARIANT: 'S' }, de: { DECIMALS: 2, DEC_POINT: '.', FORMAT_STRING: '# $', FULL_NAME: 'US-Dollar', HIDE_ZERO: 'Y', THOUSANDS_VARIANT: 'C' } } } } ) .then( function(result) { if (result.error()) { console.error(result.error()); } else { console.log(result); } }, function(error) { console.info(error); } );require_once('crest.php'); $result = CRest::call( 'crm.currency.update', [ 'ID' => 'USD', 'fields' => [ 'LANG' => [ 'en' => [ 'DECIMALS' => 2, 'DEC_POINT' => '.', 'FORMAT_STRING' => '$#', 'FULL_NAME' => 'US Dollar', 'HIDE_ZERO' => 'Y', 'THOUSANDS_VARIANT' => 'S', ], 'de' => [ 'DECIMALS' => 2, 'DEC_POINT' => '.', 'FORMAT_STRING' => '# $', 'FULL_NAME' => 'US-Dollar', 'HIDE_ZERO' => 'Y', 'THOUSANDS_VARIANT' => 'C', ] ] ] ] ); echo '<PRE>'; print_r($result); echo '</PRE>';
Response Handling
HTTP status: 200
{
"result": true,
"time": {
"start": 1717764521.938284,
"finish": 1717764522.516576,
"duration": 0.5782921314239502,
"processing": 0.07656002044677734,
"date_start": "2024-06-07T14:48:41+02:00",
"date_finish": "2024-06-07T14:48:42+02:00",
"operating": 0
}
}
Returned Data
|
Name |
Description |
|
result |
Result of the currency update. |
|
time |
Information about the request execution time. |
Error Handling
HTTP status: 400
{
"error": "",
"error_description": "Access denied."
}
|
Name |
Description |
|
error |
String error code. It may consist of digits, Latin letters, and underscores |
|
error_description |
Textual description of the error. The description is not intended to be shown to the end user in its raw form |
Possible Error Codes
|
Code |
Description |
Value |
|
Empty string |
Access denied. |
Insufficient access rights. |
|
Empty string |
The "Currency" module is not found! Please install the "Currency" module. |
|
|
|
Other errors in the data for changing the currency. |
Statuses and System Error Codes
HTTP Status: 20x, 40x, 50x
The errors described below may occur when calling any method.
|
Status |
Code |
Description |
|
|
|
An internal server error has occurred, please contact the server administrator or Bitrix24 technical support |
|
|
|
An internal server error has occurred, please contact the server administrator or Bitrix24 technical support |
|
|
|
The request intensity limit has been exceeded |
|
|
|
The current method is not allowed to be called using batch |
|
|
|
The maximum length of parameters passed to the batch method has been exceeded |
|
|
|
Invalid access token or webhook code |
|
|
|
The methods must be called using the HTTPS protocol |
|
|
|
The REST API is blocked due to overload. This is a manual individual block, to remove it you need to contact Bitrix24 technical support |
|
|
|
The REST API is available only on commercial plans |
|
|
|
The user whose access token or webhook was used to call the method lacks permissions |
|
|
|
The manifest is not available |
|
|
|
The request requires higher privileges than those provided by the webhook token |
|
|
|
The provided access token has expired |
|
|
|
The user does not have access to the application. This means that the application is installed, but the account administrator has allowed access to this application only for specific users |
|
|
|
The public part of the site is closed. To open the public part of the site on an on-premise installation, disable the option "Temporary closure of the public part of the site". Path to the setting: Desktop > Settings > Product Settings > Module Settings > Main Module > Temporary closure of the public part of the site |
Continue Learning
- Add Currency crm.currency.add
- Get Currency by ID crm.currency.get
- Get the list of currencies crm.currency.list
- Delete Currency crm.currency.delete
- Get Currency Fields crm.currency.fields