Send integration message to multiple users

Hi,
the documentation told me I will be able to send an integration message as a direct message to multiple users by using the user ids seperated by two underscores:
https://docs.mattermost.com/developer/webhooks-incoming.html#frequently-asked-questions

So I requested the user ids of the two users test and peter:

> mattermost user search test peter
id: ehjz5ejh578iib9drqkeoxdzbw
username: test
nickname: 
position: 
first_name: 
last_name: 
email: user@example.com
auth_service: 
------------------------------
id: zo48i1d7ztgpiqqhf6is1mdric
username: peter
nickname: 
position: 
first_name: 
last_name: 
email: peter@pepper.com
auth_service:

So my ids are ehjz5ejh578iib9drqkeoxdzbw and zo48i1d7ztgpiqqhf6is1mdric

But when I try to send a message like

payload = {'text': 'Hi', 'channel': 'ehjz5ejh578iib9drqkeoxdzbw__zo48i1d7ztgpiqqhf6is1mdric'}

I always receive a 403 error from the server. Sending message via a regular channel name or direct messages via @user works fine.

Does anyone have an idea what could be the problem?

Hi @flappix, thank you for reaching out.

Can you help double-check if the payload is correct - e.g. in the docs the user ids seem to come before the text. If you change the order, do you get the same error? Also, can you give more details on the error you’re seeing?

Hi, thanks for your reply.

Now I copy-pasted the payload of the faq and just changed the user ids but it did not changed anything.

The complete response is:

'Content-Type': 'application/json'
'X-Request-Id': 'z3hwyzaxc38gdma1qm6j38ig9h'
'X-Version-Id': '5.2.0.5.2.1-1.4e7659a39a744c3cfadb0b1bdd10a45c.false'
'Date': 'Mon, 10 Sep 2018 09:55:27 GMT'
'Content-Length': '165'

{
	"id":"web.incoming_webhook.channel.app_error",
	"message":"Couldn\'t find the channel",
	"detailed_error":"",
	"request_id":"z3hwyzaxc38gdma1qm6j38ig9h",
	"status_code":404
}

I’m pretty sure the last time I tried this I got a 403 instead of a 404 but I can’t reproduce it.

Hi @flappix,

According to the troubleshooting section, Couldn't find the channel means that the channel doesn’t exist or is invalid. Can you help double-check the channel parameter?

Thanks again for your reply, now I start to understand how this works.

So I looked in the Channels table of the database and see the channel names of the private channels are composed like userid1__userid2. So I have to use the right order, userid2__userid1 is not working.
For private channels consisting of more than 2 users the naming rules seems to be different. I have a private channel consisting of 3 users which is named ccb18b7a4192b361c81f806282946177b75ee3b3.

Also, I get a 403 error, permission denied if I want to post in a private channel the creator of the webhook is not a part of. There is probably no way to get around this, right?

Hi @flappix, the instructions you’re looking at in the link that you referenced (https://docs.mattermost.com/developer/webhooks-incoming.html#how-do-i-send-a-webhook-post-to-a-direct-message-channel) is for Direct Messages (meaning a channel with you and one other user or yourself). I’m not sure if it works for Group Messages or private channels with more than 2 users. In the first example that you posted a week ago, are you the user “test”?