Important Update: Community URLs redirect issues are partially resolved. Learn More. .

cancel
Showing results for 
Search instead for 
Did you mean: 

Getting 'Username Already exists' error even though it does not

AshishUpadhyay
Contributor II
We create users using the Webservices API's 'CreateUserexwithpassword' method and then update their usernames using the 'UpdateUserName' method, keeping the username the same as the email address. It nearly always works, except when we delete a user and then try to recreate it using the API, in which case we get an error that says "Server was unable to complete request. ---> The user name already exists."

We manually searched the user list  for that username and were unable to locate it; we also tested the API method 'DoesUserExist,' which returned false. Even if we try to change the username in the account manually, it won't let us, stating that the username already exists.

Any suggestions on this?

@JeffLetterman @Ilya_Khen @Ilya.Khen 

4 REPLIES 4

Anonymous
Not applicable

@AshishUpadhyay,

Probably it exists as deleted. You can search for the user in the DB tblUser. Though it should be suffixed as inactive, but depends on the approach for user deletion over API.

JeffLetterman
Archer Employee
Archer Employee

How are the users getting deleted?  Via the UI, API, SQL, other?  

Instead of using web services api, have you considered using the REST API to create user?  It allows you to specify username on creation or it will autogenerate a username...see example below.

With each new Archer version, new attributes may get added, so this is not a complete list.  To see current list of attributes in your version, make API call to get a user by id.

{
  "Password": "Password123$",
  "Notification": true,
  "Roles": [
    73,
    76,
    100
  ],
  "Groups": [
    141,
    84
  ],
  "User": {
    "FirstName": "John",
    "MiddleName": "Micheal",
    "LastName": "Doe",
    "Username": "jdoe",
    "AccountStatus": 1,
    "DomainId": null,
    "SecurityId": 1,
    "LanguageId": 2,
    "Locale": "en-US",
    "TimeZoneId": "Central Standard Time",
    "Address": "<p>123 Main St.<br/>Kansas City, KS 66112</p>",
    "Company": "ABC",
    "Title": "My Title",
    "AdditionalNote": "This is my additional notes",
    "ForcePasswordChange": true,
    "DefaultHomeDashboardId": 9,
    "DefaultHomeWorkspaceId": 14
  },
  "Contacts": [
    {
      "ContactType": 7,
      "ContactSubType": 2,
      "Value": "john.doe@abc.com",
      "IsDefault": true
    },
    {
      "ContactType": 7,
      "ContactSubType": 2,
      "Value": "john.doe2@abc.com"
    },
    {
      "ContactType": 7,
      "ContactSubType": 2,
      "Value": "john.doe3@abc.com"
    },
    {
      "ContactType": 7,
      "ContactSubType": 2,
      "Value": "john.doe4@abc.com"
    },
    {
      "ContactType": 7,
      "ContactSubType": 2,
      "Value": "john.doe5@abc.com"
    },
    {
      "ContactType": 9,
      "ContactSubType": 1,
      "Value": "111-111-1111",
      "IsDefault": true
    },
    {
      "ContactType": 9,
      "ContactSubType": 2,
      "Value": "222-222-2222"
    },
    {
      "ContactType": 9,
      "ContactSubType": 2,
      "Value": "333-333-333"
    },
    {
      "ContactType": 9,
      "ContactSubType": 2,
      "Value": "444-444-4444"
    },
    {
      "ContactType": 9,
      "ContactSubType": 2,
      "Value": "555-555-5555"
    }
  ]
}

 

AshishUpadhyay
Contributor II

@Anonymous @JeffLetterman 
Users are getting deleted via UI.
Thanks for the suggestion I will check the database and will try this method with REST API.

JeffLetterman
Archer Employee
Archer Employee

When a user is deleted via the UI/API, the username is prefixed with the user id and an underscore in the database to prevent issue with creating a new user with same username.  For example, if username was "jdoe" and user id is 208, the username becomes "208_jdoe" after deletion.  The account status id (acct_status_id) is also changed to 99999 in database.

In your example after deleting user, run SQL query against instance database to confirm the behavior is occurring correctly in your environment.