[Solved] Curl command: invite/email and user_email Array of String

I’m sending the following curl command:

curl --request POST --url 'https://mattermost.foo.com/api/v4/teams/xxxxxxxxxxxxxxxxxxxxxxxxx/invite/email' --header 'Authorization: Bearer yyyyyyyyyyyyyyyyyyyyyyyyyyyyx' --header 'Content-Type: application/json'   --data '{ "bar@foo.com", "test@foo.com" }'

But it returns an error:

{"id":"api.context.invalid_body_param.app_error","message":"Invalid or missing user_email in request body ","detailed_error":"","request_id":"bbbbbbbbbbbbbbbbbb","status_code":400}

https://api.mattermost.com/#tag/teams%2Fpaths%2F~1teams~1{team_id}~1invite~1email%2Fpost

said that I should post an array of strings. But the error said that “user_email” is missing.

But what is the correct JSON data format for this command? Which array of strings?

Thanks for your help.

Hi @Ramel, thank you for reaching out.

What browser / device and Mattermost server version are you using?

Mattermost Version: 4.7.1 (4.7.2)
and
curl 7.47.0 for the CLI

In your curl example, you are sending an (invalid) JSON object. Instead of:

--data '{ "bar@foo", "test@foo" }'

Try:

--data '["bar@foo", "test@foo"]'

See: https://json-schema.org/understanding-json-schema/reference/array.html

That’s right, and the documentation tell us to use “[ ]”. Directly an Array not an object.
Thanks DSchalla for the explanation.