Updating user name via API
Hi everyone,
I wrote a script to update a specific user (later, i would like to update many users...)
I want to update the username via the api. Is this possible?
I'm using the endpoint: POST https://api.teamdynamix.com/TDWebApi/api/people/{uid}
I authenticate fine, but when i do the post request above (using the university's assigned url, and a specific value for UID) i get the following error:
code: 400
{"ID":-1,"Message":"Could not edit user: You cannot change a user's type via the API"}
Any ideas?
Answers (2)
Hi Jorge,
I can assist you with this. The first issue is that the POST /TDWebApi/api/people/{uid} endpoint does not accept a partially inflated user object or PATCH type usage. You have to send a fully-inflated user object. This means that for each user you want to update via the API, you have to:
- Make a GET /TDWebApi/api/people/{uid} call first to get the user's full set of information.
- Make changes to the JSON object client-side.
- Save the object back to the API by calling POST /TDWebApi/api/people/{uid}.
Essentially using a search, get, update (client-side) and then save pattern.
The second issue you will experience is that the Username property, which edits the user's true username, cannot be edited via the API. That can only be changed by hand, user by user, in the Admin application by a full organizational admin. You can use the API to set or change the AuthenticationUserName username, though whether or not that would work for your organization and processes you would have to determine.
Let me know if that helps.
Since the username can be changed via the Admin application then it should be able to be done by an API. Please redesign the API to allow this. When a username (email address) is based on a person's legal name which can change then the ability to change username via an API will allow for more automation.