400 error if user is not in channel for check if member

According to the API docs, “check if member” should return a JSON response of { is_member: <boolean> }. When I make this call with a user who is present in the channel, I am receiving { is_member: true, "state"=>"joined" } as expected. However, if I provide a user who is not present, I get a 400 error with the message "User" not found instead of the expected 2xx with { is_member: false }.

Here’s the URL I’m hitting (with sensitive keys redacted):

https://{api_url}.sendbird.com/v3/group_channels/{channel_url}/members/not-in-the-channel

(I’ve tried passing UUIDs instead of not-in-the-channel as well just in case it was a string formatting issue, but no luck.)

For now I’m going to rescue the 400 error and return false, but curious if the docs are incorrect or if I’m missing something.

Thanks!

  • Kyle
1 Like

Hello @kshipley its been already a year since you posted the question :astonished: sorry that we missed it. As now, I tested same scenario and it works fine at the moment. Please let us know if you have any other questiosn!

1 Like

It was not quite that long, only a couple of months. :slight_smile: But thanks for following up!

Here’s a cURL command I just ran (with sensitive values redacted) where invalid-id is intentionally chosen to be someone who is not in the channel:

curl -X GET \
  --header "Content-Type: application/json, charset=utf8" \
  --header "Accept: application/json" \
  --header "Api-Token: {api-token}" \
  https://api-{app-id}.sendbird.com/v3/group_channels/{channel-url}/members/invalid-id

And here is the return value that I am getting with an HTTP status code of 400:

{"message":"\"User\" not found.","code":400201,"error":true}

When you say that it is working fine, does that mean that you are getting a 200 with { is_member: false } in the response body? Or is 400 the expected response status, in which case maybe the docs just need a bit of clarification?

Thanks!

1 Like

There are 3 outputs you could expect:

  1. valid user who is in the channel → { “is_member”: true } // 200
  2. valid user who is not in the channel → {“is_member”: false } // 200
  3. invalid user id → user not found // 400
1 Like

Got it - that makes sense. Thanks for clarifying!

2 Likes