API"Add a user to a team" 404 failed error

API “Add a user to a team” results in a 404 error. Please tell me the problem of my request.
Add a user to a team

curl --request POST \
     --url https://app.asana.com/api/1.0/teams/< target team GID>/addUser\
     --header 'accept: application/json' \
     --header 'authorization: < my API key >'\
     --header 'content-type: application/json' \
     --data '
{
  "data": {
    "user": "< email address of the subject >"
  }
}
'

Background: Creating tools in Python for team admins using Asana. When the script read the file with the email address, it checked if the member was registered with Asana and created a tool to add them to the team and it was working fine, but from early 2025/3 it stopped working with a 404 error.
I searched the forums and didn’t see any updates to this API.

What else have you tried?
・Run Python by rolling back to a working, low-code git
・API key reissue
・The API executor is an administrator on the target team.

For your reference, we also provide a log of API execution with Python tools.

HTTP response headers: HTTPHeaderDict({'Content-Type': 'application/json; charset=UTF-8', 'Content-Length': '196', 'Connection': 'keep-alive', 'Date': 'Sun, 16 Mar 2025 23:56:07 GMT', 'cache-control': 'no-store', 'pragma': 'no-cache', 'x-frame-options': 'DENY', 'x-xss-protection': '1; mode=block', 'x-content-type-options': 'nosniff', 'content-security-policy': "report-uri https://app.asana.com/-/csp_report?report_only=false;default-src 'none';frame-src 'none';frame-ancestors 'none'," 'x-asana-api-version': '1.0', 'asana-change': 'name=cross_workspace_deprecation;info=https://forum.asana.com/t/change-get-projects-get-users-and-get-tags-will-require-a-workspace-or-team/1031581, name=new_user_task_lists;info=https://forum.asana.com/t/update-on-our-planned-api-changes-to-user-task-lists-a-k-a-my-tasks/103828, name=new_goal_memberships;info=https://forum.asana.com/t/launched-team-sharing-for-goals/378601;affected=true', 'x-envoy-upstream-service-time': '1478', 'server': 'istio-envoy', 'X-Cache': 'Error from cloudfront', 'Via': '1.1 0c2f67f0b8f93e39e73cbead78d06c2c.cloudfront.net (CloudFront)', 'X-Amz-Cf-Pop': 'KIX56-C1', 'X-Amz-Cf-Id': 'mleF1_gUqLg6HPES5IJBcsMkHf997n3FeNuLdkN-6jn2Ka-Zowx7bA==', 'Referrer-Policy': 'strict-origin-when-cross-origin', 'Strict-Transport-Security': 'max-age=31536000; includeSubDomains; preload', 'X-Robots-Tag': 'none', 'X-UA-Compatible': 'IE=edge,chrome=1'})
HTTP response body: b'{"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://developers.asana.com/docs/errors"}]}'

Thanks.

Hi and welcome @Yano_Hiroki_矢野_大暉,

Over the past few months, there have been several changes in how Asana handles team (and project) permissions and access. My first guess as to the source of your issue is that the user who you’re authenticating with is no longer a member of the team being specified in your team_gid. (You have a space in your example curl request where the team gid goes; I’m assuming that’s only in what you posted here and not in your actual request.)

Thank you @Phil_Seeman for your reply.
The Python code actually specifies team_gid.
I called a simple API like the one below, and it worked until around 2025/2.
Around 2025/3, all of a sudden the 404 error I mentioned earlier started appearing.


def add_user_to_team(team_gid: str, user: str):
    """Add the specified user to the specified team
    see: https://developers.asana.com/reference/adduserforteam

    Args:
        team_gid (str): GID of the team to which you want to add the user
        user (str): GID or email address of the user to be added
    """
    teams_api_instance = asana.TeamsApi(api_client)
    body = {"data": {"user": user}} # dict | The user to remove from the team.
    opts = {
        "opt_fields": "team,team.name"
    }

    try:
        teams_api_instance.add_user_for_team(body, team_gid, opts)
    except ApiException as e:
        print("Exception when calling TeamsApi->add_user_for_team: %s\n" % e)
        raise e

Since this team_gid was able to check the information with "get_team"API like below beforehand, I think there is no problem.
api_response = teams_api_instance.get_team(team_gid, opts)

If there are any corrections, please let me know.
Thank you very much.

Hmm, interesting. Not sure what the issue is.

@John_Vu @Andrew-asana any ideas?

Thanks for help out @Phil_Seeman

@Yano_Hiroki_矢野_大暉 The error that you got “No matching route for request” is probably related to what @Phil_Seeman said about "You have a space in your example curl request where the team gid goes". Try this:

cURL command:

curl --location 'https://app.asana.com/api/1.0/teams/<TEAM_GID>/addUser' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer <ASANA_PERSONAL_ACCESS_TOKEN>' \
--data '{
  "data": {
    "user": "<USER_ID_OR_EMAIL>"
  }
}'

@Yano_Hiroki_矢野_大暉 I tested your python code and it looks right. Make sure you are passing in a valid <TEAM_GID>. I tested the python script out with a random ID for <TEAM_GID> and got a 404 error.

Python (v5.1.0):

import asana
from asana.rest import ApiException
from pprint import pprint

configuration = asana.Configuration()
configuration.access_token = "<ASANA_PERSONAL_ACCESS_TOKEN>"
api_client = asana.ApiClient(configuration)


def add_user_to_team(team_gid: str, user: str):
    """Add the specified user to the specified team
    see: https://developers.asana.com/reference/adduserforteam

    Args:
        team_gid (str): GID of the team to which you want to add the user
        user (str): GID or email address of the user to be added
    """
    teams_api_instance = asana.TeamsApi(api_client)
    body = {"data": {"user": user}} # dict | The user to remove from the team.
    opts = {
        "opt_fields": "team,team.name"
    }

    try:
        res = teams_api_instance.add_user_for_team(body, team_gid, opts)
        pprint(res)
    except ApiException as e:
        print("Exception when calling TeamsApi->add_user_for_team: %s\n" % e)
        raise e
    
add_user_to_team("<TEAM_GID>", "<USER_GID>") # Replace with the GID of the team and the GID or email address of the user to be added

1 Like

@Phil_Seeman @John_Vu
Thank you for your reply!
Currently, there is no error when executing the same code described in the forum, and as of 2025-03-19 15:00 (JST), this error no longer occurs.
However, at least this error occurred between 2025/3/12 15:54 and 2025/3/17 14:00 (JST).
I did not correct the code, and I did not check the network trouble at the time mentioned above. I think it is a server trouble on Asana side, so I asked the support to deal with it.
However, it is not possible to reproduce it now, so if there is anyone who has experienced the same thing, I would be happy if you continue to provide information.

Yes. This looks to be the case. I confirmed with our API and Infra team that there was a small outage that has since been fixed.

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.