Adding members to a project


#1

Hey all,

I’m looking for a way to add users to an Asana project using the API.
The users are not part of any previous team and are given at random.

Thanks for the help,

Aviv


#2

Hey @Aviv_Farhi,

Have you tired:

POST /projects/{project_gid}/addMembers

This request adds a specified list of users as members to the project. Here are the docs.


#4

Hey, thanks for the reply.
I haven’t tried that but I doubt it would work.
You see, I need to add a user that is not currently a member.
I intend to add the new user using email since I have no user ID.


#5

The Asana API doesn’t provide the ability to create a new Asana user, so unfortunately you won’t be able to do what you’ve described.


#6

Hey @Aviv_Farhi,

You can try using our addUser endpoint to invite new users to a domain:

POST /workspaces/{workspace_gid}/addUser

Here are the docs for user management.


#7

@Jeff_Schneider - the user whose email address you send to addUser has to have an Asana account (i.e. be a known Asana user), correct? Or can it be a new unknown email address and that endpoint will create a user account?


#8

Hey @Phil_Seeman, good question (and probably something we should make more clear on our docs). You can invite people who have a random email. Once they accept the invite, they will join the Asana organization as a guest.


#9

Oh, that’s very cool!


#10

Hi @Jeff_Schneider I tried using this method, but I received a weird response:

{"errors":[{"message":"No matching route for request","help":"For more information on API status codes and how to handle them, read the docs on errors: https://asana.com/developers/documentation/getting-started/errors"}]} 

I tried using the following methods:

curl -H -XPOST -H "content-type: application/json" -H "Authorization: Bearer 0/xxx" https://app.asana.com/api/1.0/workspaces/123/addUser -d '{"data": {"user": "elad@elad.com" }}'

Also tried:

curl -X POST -H "content-type: application/json" -H "Authorization: Bearer 0/xxx" https://app.asana.com/api/1.0/workspaces/123/addUser?user=elad@elad.net

And:
url -H "Authorization: Bearer 0/xxx" https://app.asana.com/api/1.0//workspaces/123/addUser -d '{"workspace_gid": "123", "user": "elad@elad.net" }'

And:

url -H "Authorization: Bearer 0/xxx" https://app.asana.com/api/1.0//workspaces/123/addUser -d '{"data":{"workspace_gid": "123", "user": "elad@elad.net" }}'

But none worked, each return a different error.


#11

try passing the data as form urlencoded string like below and that should work!
curl -X POST https://app.asana.com/api/1.0/workspaces/123/addUser -H ‘Authorization: Bearer 0/xxxxxxx’ -d ‘user=elad@elad.net’,