Address.create API call: Untranslated province names are invalid options for field state_province_id
When calling the Address.create
API call with a state_province_id
set to the untranslated name of a province (as in its name
attribute in the DB), and this province being translated in the current default language, an API error 'XYZ' is not a valid option for field state_province_id
is returned and the address is not being created/updated.
Being aware of this field ideally receiving the actual state_province ID instead of its name, this might be a minor issue, but it makes manual imports a mess, if we'd have to issue another API call first to retrieve the ID from the untranslated name, which is the actual value in the DB. So this error causes quite some confusion.
Steps to reproduce:
- Set CiviCRM's default language to e.g. German
- Find a state province which is translated (e.g. Switzerland's Geneva, which is "Genf" in German)
- Issue an
Address.create
API call with the following parameters:
{
"contact_id": 123, // A valid contact ID
"location_type_id": "Home",
"country_id": "CH",
"state_province_id": "Geneva",
}
- Notice the API error.