You might see that the Dropbox Community team have been busy working on some major updates to the Community itself! So, here is some info on what’s changed, what’s staying the same and what you can expect from the Dropbox Community overall.
Forum Discussion
JohnAdam_CUNY
5 months agoHelpful | Level 6
Error updating Preferred Name ( New First and Last name )
We got a requirement to update our Dropbox first and last name. Is it simply to to use info to update an existing user Dropbox first name and last name. Our wrote the code using json API but not as f...
- 5 months ago
Documentation is not clear. See solution. Please advise if I misunderstood anything.
team_members_set_profile_v2(user, new_email=None, new_external_id=None, new_given_name=None, new_surname=None, new_persistent_id=None, new_is_directory_restricted=None)
if len(fname) != 0:
result = dbx_team.team_members_set_profile_v2(user=user, new_given_name=fname)
print(result)
if len(lname) != 0:
result = dbx_team.team_members_set_profile_v2(user=user, new_surname=lname)
print(result)
Greg-DB
Dropbox Staff
In the code snippet you shared here, I see you're calling team_members_get_info_v2, which is a way to read the information for some team member(s). That doesn't change their information on Dropbox. If you want to change their member information (like first/last name) you should use team_members_set_profile_v2.
In any case, if something isn't working as expected, please share both the code and the unexpected error or output. (I see you mentioned getting an error in the title for this thread, but it doesn't look like you included that error output here.)
JohnAdam_CUNY
5 months agoHelpful | Level 6
I checked the documentation but looking for clarification since we still use the old json API for 95% of our teams we are learning the new Python SDK for 1 team.
Instead of user do I pass the below. Can you provide an example of updating fname and lname for below?
## New Code
user = dropbox.team.UserSelectorArg.email(dropboxemail)
result = dbx_team.team_members_set_profile_v2([user])
print(result)
##OlD Get Info Code
for info in result.members_info:
if info.is_member_info():
if len(new_email) != 0:
info.get_member_info().profile.email = new_email
if len(fname) != 0:
info.get_member_info().profile.name.given_name = fname
if len(lname) != 0:
nfo.get_member_info().profile.name.surname = lname
if len(emplid) != 0:
info.get_member_info().profile.persistent_id = emplid
if len(newExID) != 0:
info.get_member_info().profile.external_id = newExID
#######################################################################################
print("\n\nName is : " + str(info.get_member_info().profile.name) )
print("\nFirst name is : " + str(info.get_member_info().profile.name.given_name))
print("Last Name is : " + str(info.get_member_info().profile.name.surname))
print("Account ID : " + info.get_member_info().profile.team_member_id)
print("Email is : " + info.get_member_info().profile.email)
print("\nPersistent ID is : " + info.get_member_info().profile.persistent_id)
print("External ID is : " + info.get_member_info().profile.external_id)
elif info.is_id_not_found():
print("User not found.")
else:
print("Other scenario not anticipated. Need to traige...")
- Greg-DB5 months agoDropbox Staff
JohnAdam_CUNY I don't believe we have sample code handy for team_members_set_profile_v2 in particular, so please refer to the documentation for information on the parameters to use with that method. For example, it sounds like you'd need to use the "user", "new_given_name", and "new_surname" for your use case.
Please try that out and if it doesn't work for you, please share the relevant code and output so we can help troubleshoot.
- JohnAdam_CUNY5 months agoHelpful | Level 6
See below issue it appears not to accept my variables.
Test #1
dbx_team = dropbox.DropboxTeam(
oauth2_refresh_token=REFRESH_TOKEN,
app_key=APP_KEY,
app_secret=APP_SECRET)
user = dropbox.team.UserSelectorArg.email(dropboxemailif len(new_email) != 0:
result = dbx_team.team_members_set_profile_v2([user],new_email=new_email)
print(result)
if len(fname) != 0:
result = dbx_team.team_members_set_profile_v2([user],info.get_member_info().profile.name.given_name = fname)
print(result)
if len(lname) != 0:
result = dbx_team.team_members_set_profile_v2([user], info.get_member_info().profile.name.new_surname=lname)
print(result)
Error:
C:\Users\jdebh\Anaconda3\python.exe "S:\Academic Collaboration Technology\DROP BOX\DropboxPROD\CORECODE\OAUTH_COSEN_SET_INFO.py"
File "S:\Academic Collaboration Technology\DROP BOX\DropboxPROD\CORECODE\OAUTH_COSEN_SET_INFO.py", line 30
result = dbx_team.team_members_set_profile_v2([user],info.get_member_info().profile.name.given_name = fname)
^
SyntaxError: expression cannot contain assignment, perhaps you meant "=="?Process finished with exit code 1
Test #2dbx_team = dropbox.DropboxTeam(
oauth2_refresh_token=REFRESH_TOKEN,
app_key=APP_KEY,
app_secret=APP_SECRET)
user = dropbox.team.UserSelectorArg.email(dropboxemail)if len(new_email) != 0:
result = dbx_team.team_members_set_profile_v2([user],new_email=new_email)
print(result)
if len(fname) != 0:
result = dbx_team.team_members_set_profile_v2([user], new_given_name=str(fname))
print(result)
if len(lname) != 0:
result = dbx_team.team_members_set_profile_v2([user], new_surname=str(lname))
print(result)
Error:
Traceback (most recent call last):
File "S:\Academic Collaboration Technology\DROP BOX\DropboxPROD\CORECODE\OAUTH_COSEN_SET_INFO.py", line 32, in <module>
result = dbx_team.team_members_set_profile_v2([user], new_given_name=str(fname))
File "C:\Users\jdebh\Anaconda3\lib\site-packages\dropbox\base_team.py", line 2065, in team_members_set_profile_v2
arg = team.MembersSetProfileArg(user,
File "C:\Users\jdebh\Anaconda3\lib\site-packages\dropbox\team.py", line 9112, in __init__
self.user = user
File "C:\Users\jdebh\Anaconda3\lib\site-packages\stone\backends\python_rsrc\stone_base.py", line 79, in __set__
self.validator.validate_type_only(value)
File "C:\Users\jdebh\Anaconda3\lib\site-packages\stone\backends\python_rsrc\stone_validators.py", line 612, in validate_type_only
raise ValidationError('expected type %s or subtype, got %s' %
stone.backends.python_rsrc.stone_validators.ValidationError: expected type dropbox.team.UserSelectorArg or subtype, got list- JohnAdam_CUNY5 months agoHelpful | Level 6
Documentation is not clear. See solution. Please advise if I misunderstood anything.
team_members_set_profile_v2(user, new_email=None, new_external_id=None, new_given_name=None, new_surname=None, new_persistent_id=None, new_is_directory_restricted=None)
if len(fname) != 0:
result = dbx_team.team_members_set_profile_v2(user=user, new_given_name=fname)
print(result)
if len(lname) != 0:
result = dbx_team.team_members_set_profile_v2(user=user, new_surname=lname)
print(result)
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
5,884 PostsLatest Activity: 5 hours agoIf you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X or Facebook.
For more info on available support options for your Dropbox plan, see this article.
If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!