1

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"
WhoAmI
  • 179
  • 1
  • 4
  • 8

1 Answers1

2

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.

e.g.

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.