I was using following GitHub CLI command to add new member to a GitHub org through the command line. I am using the username to add:
# GitHub CLI api
# https://cli.github.com/manual/gh_api
gh api \
--method PUT \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
/orgs/ORG/teams/TEAM_SLUG/memberships/USERNAME \
-f role='maintainer'
However, I want to invite using Email ID, because a simple typo in the username may invite the wrong members.
I tried the code below, but it results in "gh not found 404 error":
gh api \
--method PUT \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
/orgs/ORG/teams/TEAM_SLUG/memberships \
-f email='NEW_MEMBER_EMAIL' \
-f role='maintainer'
How can I fix this?