# createChannelWithUserIds throws SendBirdException: Invalid parameter

**URL:** https://community.sendbird.com/t/createchannelwithuserids-throws-sendbirdexception-invalid-parameter/4344
**Category:** JavaScript
**Tags:** group-channel
**Created:** [April 4, 2022, 5:44pm UTC](https://community.sendbird.com/t/createchannelwithuserids-throws-sendbirdexception-invalid-parameter/4344 "2022-04-04T17:44:10Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![MCastanho](https://avatars.discourse-cdn.com/v4/letter/m/eada6e/32.png) [@MCastanho](https://community.sendbird.com/u/MCastanho)
#### Post date: [April 4, 2022, 5:44pm UTC](https://community.sendbird.com/t/createchannelwithuserids-throws-sendbirdexception-invalid-parameter/4344/1 "2022-04-04T17:44:11Z")

</div>

I’m using Sendbird v3.1.10 in a React application with TypeScript.  
I’m trying to create a channel with user Ids by calling `createChannelWithUserIds()`.  
The Type Definitions say that a possible syntax is

```javascript
    createChannelWithUserIds(
      userIds: Array<string>,
      isDistinct: boolean,
      name: string,
      coverUrlOrImageFile: string | FileType,
      data: string,
      customType: string,
      callback?: groupChannelCallback // notice that this can be undefined
    ): Promise<GroupChannel>;

```

However any call I make without specifying a `callback` throws a `SendBirdException: Invalid parameter`, which is not a very informative error - took me a while to understand which was the parameter that was causing the issue.

This doesn’t work:

```javascript
sb.GroupChannel.createChannelWithUserIds(userIds, false, channelName, "", "", "") // no callback

```

This doesn’t work:

```javascript
sb.GroupChannel.createChannelWithUserIds(userIds, false, channelName, "", "", "", undefined) // undefined callback

```

This works:

```javascript
sb.GroupChannel.createChannelWithUserIds(userIds, false, channelName, "", "", "", (c) => {})

```

Can you make it so that the `callback` parameter is **really** optional as the type definitions say?

It would also be cool if all other parameters but the `userIds` were also optional so that we don’t have to set them as empty strings in order for it to work, that’s just silly.

Thanks!

---

<div class="post-metadata">

### Author: ![Tyler](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/tyler/32/810_2.png) [@Tyler](https://community.sendbird.com/u/Tyler)
#### Post date: [April 4, 2022, 6:06pm UTC](https://community.sendbird.com/t/createchannelwithuserids-throws-sendbirdexception-invalid-parameter/4344/2 "2022-04-04T18:06:52Z")

</div>

Hi @MCastanho,

Welcome to the Sendbird Community.

In order to try and better understand the overall issue, can you tell me why you’d want to create a channel via the SDK and not have a callback or promise? Seems like you’d want to get the resulting channel back.

---

<div class="post-metadata">

### Author: ![MCastanho](https://avatars.discourse-cdn.com/v4/letter/m/eada6e/32.png) [@MCastanho](https://community.sendbird.com/u/MCastanho)
#### Post date: [April 5, 2022, 9:05am UTC](https://community.sendbird.com/t/createchannelwithuserids-throws-sendbirdexception-invalid-parameter/4344/3 "2022-04-05T09:05:05Z")

</div>

Hi @Tyler ,

Thanks.

I am using a promise, I just didn’t write it there to make the code snippets compact.  
I am doing this:

```javascript
sb.GroupChannel.createChannelWithUserIds(userIds, false, channelName, "", "", "", (c) => {})
  .then((channel) => {/* send a message to this channel */})

```

And in the meantime I realized there’s a possible syntax for this function that takes only the `userIds` and an **optional** `callback`, like this:

```javascript
sb.GroupChannel.createChannelWithUserIds(userIds, (c) => {})
  .then((channel) => {/* send a message to this channel */})

```

But neither of them work if I remove the `callback`, which makes the `callback` not optional, contrary to what the documentation and types definition suggest.

---

<div class="post-metadata">

### Author: ![Tyler](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/tyler/32/810_2.png) [@Tyler](https://community.sendbird.com/u/Tyler)
#### Post date: [April 5, 2022, 3:19pm UTC](https://community.sendbird.com/t/createchannelwithuserids-throws-sendbirdexception-invalid-parameter/4344/4 "2022-04-05T15:19:41Z")

</div>

Hi @MCastanho,

Let me dig into this and see why this is happening. I’ll circle back when I have some more information.

---

<div class="post-metadata">

### Author: ![Tyler](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/tyler/32/810_2.png) [@Tyler](https://community.sendbird.com/u/Tyler)
#### Post date: [April 5, 2022, 11:21pm UTC](https://community.sendbird.com/t/createchannelwithuserids-throws-sendbirdexception-invalid-parameter/4344/5 "2022-04-05T23:21:37Z")

</div>

Hi @MCastanho,

I’ve confirmed that there is in fact an issue with `createChannelWithUserIds`. This issue actually exists with `updateChannel` as well.

While we look to get this corrected long term, you can work around this by calling `createChannel` directly while passing in an instance of `GroupChannelParams`. A quick example to achieve the same as `createChannelWithUserIds` would be this (Matching your above example):

```javascript
const sb = SendBird.getInstance();
const params = new sb.GroupChannelParams();
params.addUserIds(['exampleUser01', 'exampleUser02']);
params.isDistinct = false;
params.name = channelName
const channel = await sb.GroupChannel.createChannel(params);

```
