Chatbot POST 400 response

Hello! I have what is hopefully something that’s just a small oversight on my part, but I’ve tried everything I can think of and no luck.

Context

I (successfully) built a Chatbot app that works for me locally :tada:. The app has the imchat:bot and chat_channel:read:admin scopes and everything about it works properly: authentication, sending a custom welcome message via the chatbot on install, getting the list of channels in an account, and posting chatbot messages to a chosen channel.

That was all great, so I decided to set up a new version of the app so that everyone on my team could test it out on a sandbox environment. To do this, instead of creating the app under my own user in Zoom, I created it under our shared engineering team user so that everyone else would have access to modify it too. Both my user and the shared user are in the same Zoom account.

The issue

Long story short, the new app that I created under the shared account almost works, but fails ONLY on the last step when it’s trying to POST a message to a channel. Auth works, it sends the custom welcome message as a reply to the install webhook, it gets the list of channels in the workspace… but even though the code is exactly the same, the Chatbot API is responding with a 400 code and I can’t for the life of me figure out why.

What I’ve tried to fix this

Many things which didn’t fix it, including:

  • Attempting with both production and development credentials.
  • Sending the most basic of messages to the API to avoid any accidental formatting issues in the message.
  • Trying with markdown support either enabled or disabled.
  • Giving the shared user the exact same role that I have, in case it was a permissions issue. The shared user is also a licensed account.
  • Installing the app while logged in to my own account, and trying again while logged in to the shared account.
  • More than triple checking that all the credentials, bot IDs, and whatnot, are correct.
  • POST-ing to both https://zoom.us/v2/im/chat/messages and https://api.zoom.us/v2/im/chat/messages cause both are used in the docs.

What I really don’t understand is why the app created from my own account works without issue, but the one that I created with the shared account does not work – and it only fails on this one API call. If the Chatbot wasn’t even being installed I’d understand that something was going wrong, but I can see the Chatbot in the Zoom client and I have access tokens for both the Chatbot API and OAuth APIs for it.

We have many Zoom Apps that have been created with this shared account and have never run into this problem before, this is the first Chatbot we’ve made though. It’s not enough of a solution for me to create the app from my own account and publish that to the marketplace when we’re ready, I need others on the team to be able to access it too.

Example

With actual values replaced. This is the request body we’re sending in Python.

{
    'robot_jid': 'abc@xmpp.zoom.us',
    'to_jid': 'abc123@conference.xmpp.zoom.us',
    'account_id': 'abc-def', 
    'is_markdown_support': True,
    'content': {
        'head': {
            'text': 'hello'
        }
    }
}

With the authorization header like this:

{'Authorization': 'Bearer thisIsATokenThatIHaveReplaced', 'Content-Type': 'application/json'}

And the error I’m getting is:
400 Client Error: Bad Request for url: https://zoom.us/v2/im/chat/messages

I’d appreciate help with this please! I’m all out of ideas.

I’m still having this issue, but do have an update that’s hopefully starting to lead somewhere!

Right after I posted, this forum post was suggested which suggests that the user_jid value is required when the docs say it’s optional. I’m pretty sure it really is optional cause my local bot is working without it (and having it be required would mess with what I’m planning, please don’t update it!), but I tried sending a value along to see if it would solve the problem.

It didn’t, but I got a new error message at least! It seems like it might have been a red herring, and the real error is this one:
{"code":7004,"message":"No channel or user can be found with the given to_jid.","result":false}

The channel with the to_jid definitely does exist though. It’s a public channel in my account, and the bot itself got the ID from the API so it should have access to it. It also doesn’t work when I try to send the message to my own Zoom user ID.

I can also verify that my account has all of the chat-related permissions:

And then in the API section:

Another update, I’ve solved this!

Looks like the error message I got in the last post I made was also a red herring. The to_jid field was in fact correct unlike what the error says, and it’s the user_jid that wasn’t correct – I was passing an ID instead of a JID I believe.

So to recap: the user_jid field that the docs say is optional is in fact optional when you’re making the bot on your own account and authorizing from that account… but seems to be required in all other cases.

Hope that helps others!

1 Like