This question already has an answer here:

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"

marked as duplicate by G-Man, Isaac, Thomas, peterh, JigglyNaga Dec 3 '18 at 10:48

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


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.