Created
December 17, 2014 22:09
-
-
Save afeld/fb9b2a36f9a7b58b63d7 to your computer and use it in GitHub Desktop.
add multiple people on Trello
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
emails = %w( | |
... | |
) | |
require 'rest_client' | |
ORG = 'YOUR_ORG_SHORTNAME' | |
KEY = 'YOUR_KEY' | |
# visit this URL w/ your key replaced to get a token | |
# https://trello.com/1/authorize?key=KEY&expiration=1day&response_type=token&scope=read,write | |
TOKEN = 'YOUR_TOKEN' | |
emails.each do |email| | |
print "Adding #{email}..." | |
begin | |
# change the `type` if you don't want everyone to be an admin, but know that it will overwrite existing roles (including yourself) | |
# https://trello.com/docs/api/organization/index.html#put-1-organizations-idorg-or-name-members | |
RestClient.put("https://api.trello.com/1/organizations/#{ORG}/members?key=#{KEY}&token=#{TOKEN}", email: email, type: 'admin') | |
rescue RestClient::Unauthorized => e | |
puts e.response | |
rescue RestClient::Forbidden => e | |
puts e.response | |
else | |
puts "done" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment