Errors Explained

LAST EDIT Oct 04 2024

This section explains how to solve common API errors.

GetOrCreateChannel failed

Copied!

The full error you receive is "GetOrCreateChannel failed with error: "either data.created_by or data.created_by_id must be provided when using server side auth." with error code 4. This error is only triggered when using server side authentication.

You can encounter this error when calling channel.watch(), channel.create() or channel.query(). All three methods call get or create a channel. There are two possible causes for this error:

1. You are trying to watch a channel that hasn't been created

You are expecting that the channel is already created. For instance if you have the following code:

The above code works well if the channel with cid messaging:123 already exists. If it doesn't exist yet it will throw the above error. So you can get this error when calling channel.watch if another part of your code failed to create the channel.

2. You want to create a channel but forgot the created_by_id param

If you're actually intending to create a channel in this part of your code you need to specify the user as follows: