User Management through API - Trouble with adding / deleting users

I'm starting to write some python scripts to interface with the API to use for User Management.  I've been able to successfully extract existing users and update user permissions using a similar version of the script provided as an example from Team Viewer API (i.e. ExportUserCSV.py and ImportUserCSV.py). 

I'm now trying to add/remove single users through the API as well.  It looks like I've been able to add the user (i.e. user received the welcome email).  However, in my attempt to deactivate the user, it looks like it has entered an unknown state.  For example, if I try to retrieve that user from the API, it can't find it (email purposely obscured): 

 

Get single user by mail (user@company.com)
Request [GET] https://webapi.teamviewer.com/api/v1/users?email=user@company.com&full_list=true
200
Request ok!
Result: {'users': []}
No user with email=user@company.com found.

However, when I try to create that user (again), I'm getting an error that the email is already used: 

Creating user [user@company.com]
Request [POST] https://webapi.teamviewer.com/api/v1/users
Payload :{"name": "User Name", "email": "user@company.com", "password": "somePassWord", "permissions": "ShareOwnGroups,Edit
Connections,EditFullProfile,ViewOwnConnections", "language": "en"}
Headers :{'Authorization': 'Bearer 123456-BLABLABLABLABLA', 'Content-Type': 'application/json; charset=utf-8', 'Co
ntent-Length': '42'}
400
Unexpected response code. Received content was:
{"error":"invalid_request","error_description":"This e-mail address is already in use","error_code":1}

 I also tried updating the user, setting the 'action' to True, however, it first needs to find the email first, and, as mentioned in the previous block, it can't find that email. 

Any suggestions on how to either completely remove that User/email or activate the existing user?  

Comments

  • Ok, I can answer my own question.  The colleague I was trying to add already had a TeamViewer account with his work email.  This is why it couldn't find the email when looking up under our organization, but said that the email was already being used. 

  • DomLan
    DomLan Posts: 490 ⭐Star⭐

    Hi @mshrive3,

    Your answer is correct.
    In any case you can still associate the specific account with your TeamViewer Company license, keeping the specific email address.

    To do this it is necessary that the user, with his/her own credentials, connect to the site https://login.teamviewer.com/cmd/joincompany.

    Here he/she will enter the email address of an account with administrator rights for a specific company (for example yours) and accept the request to grant the company all rights to their account.

    In your management console you will find this user's request to join your company and you will have to accept it.

    I hope it helps you.

    Regards

    Domenico Langone

    MCSD: App Builder

  • Thank you so much @DomLan!