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's avatar
JohnAdam_CUNY
Helpful | Level 6
6 months ago

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 familiar with Python SDK. Any help is greatly appreciated

 I tried below but it doesnt update the data.

 

 

user = dropbox.team.UserSelectorArg.email(dropboxemail)
result = dbx_team.team_members_get_info_v2([user])
print(result)

for info in result.members_info:
if info.is_member_info():
print("\n\nName is : " + str(info.get_member_info().profile.name) )
print("\n\nFirst Name is : " + str(info.get_member_info().profile.name.given_name))
print("\n\nLast 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)

  • JohnAdam_CUNY's avatar
    JohnAdam_CUNY
    6 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's avatar
    Greg-DB
    Icon for Dropbox Staff rankDropbox 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's avatar
      JohnAdam_CUNY
      Helpful | 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-DB's avatar
        Greg-DB
        Icon for Dropbox Staff rankDropbox 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.

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

5,910 PostsLatest Activity: 4 days ago
333 Following

If 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!