How to put the variable "user" in this array. The way it is not it doesn't work sadly. The $user variable should be john.smith for example.

I have the following output:

curl --header "Authorization: Bearer XXXXXXXX" --request POST --data '["$user@test.com"]' "https://mattermost.test.com/api/v4/teams/$team/invite/email"

The problem is your use of single quotes (') in the --data field. This prevents the shell from expanding variables.

Compare echo '$user' to echo "$user" and you'll see the problem.

There's a number of ways to handle this, but one way is to close/open the ' around the variable.


curl --header "Authorization: Bearer XXXXXXXX" --request POST --data '["'$user'@test.com"]' "https://mattermost.test.com/api/v4/teams/$team/invite/email"

The reason you don't see this with your Bearer token is because you're using ", which allows the variable to be expanded.

Not the answer you're looking for? Browse other questions tagged or ask your own question.