A simple question, I am attempting to Upsert User records into Salesforce by using 'Username' as the External Id. But I am receiving the following 'DUPLICATE_USERNAME' error:
"Duplicate Username.
The username already exists in this or another Salesforce organization. Usernames must be unique across all Salesforce organizations. To resolve, use a different username (it doesn't need to match the user's email address). DUPLICATE_USERNAME"
I know there is already a user in my org with this exact 'Username', so I would expect the record to be updated, and as it's not creating a new record the duplicate username shouldn't be an issue?... Is my understanding of the Upsert operation incorrect?
Postman Upsert Request:
curl --location --request PATCH 'https://************.my.salesforce.com/services/data/v51.0/sobjects/User/Username/srj@************.co.uk.Invalid' \
--header 'Authorization: Bearer ************' \
--header 'Content-Type: application/json' \
--data-raw '{
"FirstName": "S",
"LastName": "RJ",
"Alias": "srj",
"Email": "srj@example.com",
"ContactId": "0031w00000nviAVAAY",
"ProfileId": "00e1w000000I0GEAA0",
"CommunityNickname": "srj",
"EmailEncodingKey": "UTF-8",
"TimeZoneSidKey": "Europe/London",
"LocaleSidKey": "en_GB",
"LanguageLocaleKey": "en_US"
}'
Postman Upsert 400 Response:
[
{
"message": "Duplicate Username.<br>The username already exists in this or another Salesforce organization. Usernames must be unique across all Salesforce organizations. To resolve, use a different username (it doesn't need to match the user's email address). ",
"errorCode": "DUPLICATE_USERNAME",
"fields": [
"Username"
]
}
]
Many Thanks