Skip to content

Instantly share code, notes, and snippets.

@cbare
Created March 13, 2015 05:23
Show Gist options
  • Select an option

  • Save cbare/5d7cd8c7eb9ad0fca1d4 to your computer and use it in GitHub Desktop.

Select an option

Save cbare/5d7cd8c7eb9ad0fca1d4 to your computer and use it in GitHub Desktop.
Example of how to add participants with pending join requests to a team
import synapseclient
from synapseclient.exceptions import SynapseError
team_id = "3325290"
approved_participant_ids = ["377358", "3321663"]
syn = synapseclient.Synapse()
## log in using cached API key.
syn.login()
for principal_id in approved_participant_ids:
try:
syn.restPUT("/team/%s/member/%s" % (team_id, principal_id))
except SynapseError as ex1:
print ex1
# Adding to a team is a two step process. Either the user has to be invited, then accept or they have to
# request membership then be approved. Either way, membership requires action from both a "team manager"
# and the individual member.
# Synapse's way of saying:
# 1) there's no join request or
# 2) the user is already a member of the team or
# 3) the calling user is not a team manager
# ...is this:
# 403 Client Error: Forbidden Cannot add member to Team.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment