Bad-Request error in grantMemberShip() XMPP Smack

162 Views Asked by At

I am using Smack library for XMPP, but getting bad-request error, when trying to invite user and giving him permission of Admin (When I created a room).

Code :

    try{
        muc.grantMembership(userId);
    } catch (XMPPException.XMPPErrorException e) {
        e.printStackTrace();
    } catch (SmackException.NoResponseException e) {
        e.printStackTrace();
    }
    muc.invite(userId, "Join a group chat");

Please help me to solve this issue. Thanks

1

There are 1 best solutions below

0
MrPk On

There are many failure points, check in your code what you miss:

  1. Owner and or Admins must be setted while sending Configuration Form to server
  2. To grant membership, multiuserchat must be persistant (check again Configuration Form)
  3. To grant membership and send invitation, user must be at least an Admin.
  4. userid must be valorized by a bareJID (example: user@server)
  5. Server must supports persistant groupchats
  6. To grant membership or invitation, user must already joined the room