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?

 

Tags API web-api
Asked by Jorge Gasca on Tue 11/5/19 3:51 PM
Sign In to leave feedback or contribute an answer

Answers (2)

This answer has been marked as the accepted answer
Matt Sayers Tue 11/5/19 4:02 PM

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:

  1. Make a GET /TDWebApi/api/people/{uid} call first to get the user's full set of information.
  2. Make changes to the JSON object client-side.
  3. 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.

3 of 3 users found this helpful.
Hi Matt, sorry to necro this old post, but can the TeamDynamix team please update the API documentation for the POST operation to update people and indicate that the UserName cannot be updated through the API? I just spent a bunch of time coding around the UserName being updatable and only when it didn't work and I searched for reasons did I find out this information here. There is already a Remarks box describing that the password, organization, and user type cannot be updated but seems to omit that the user name cannot be updated. Thanks, Rob - Rob Lamb Wed 9/20/23 2:15 PM

David Darus Fri 12/8/23 7:53 AM

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.

No feedback