Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

BlackBerry Web Services

Reply
Contributor
Posts: 15
Registered: ‎08-14-2013
My Device: Bold 9000
My Carrier: T-Mobile
Accepted Solution

How to delete a user using the BWS

Hi,

 

I'm working on a little app that can delete multiple user from the BAS. I'm using the BWS for this, but something is not clear.

My function is this:

 

        public static bool DeleteUser(string[] inputEmail)
        {
            DeleteUsersRequest UserDeleteRequest = new DeleteUsersRequest();
            UserDeleteRequest.metadata = BasicSettingData.Metadata;

            User egy = new User();
            User[] DeletableUserArray = new User[1]{egy};
            DeletableUserArray[0].emailAddresses = inputEmail;
            UserDeleteRequest.users = DeletableUserArray;

            DeleteUsersResponse UserDeleteResponse = new DeleteUsersResponse();

            try
            {
                UserDeleteResponse = BasicSettingData.bwsService.deleteUsers(UserDeleteRequest);
            }
            catch (Exception e)
            {
                MessageBox.Show( e.Message + "     " + e.StackTrace);
                return false;
            }
            if (UserDeleteResponse.returnStatus.code.Equals("SUCCESS"))
            {
                MessageBox.Show("trololololololo");
            }

            return true;

 The function throw no error or exception, however the users are not deleted. I'm defenetly missed something, just don't know what. :smileyhappy:

Retired
Posts: 2,559
Registered: ‎10-16-2009
My Device: BlackBerry Z10
My Carrier: Bell

Re: How to delete a user using the BWS

In your function you create the User object, then use that same User object to attempt deletion. You instead need to grab the User(s) you want to delete from a getUsers() call.

Garett
@garettBeuk
--
Goodbye everybody!
Contributor
Posts: 15
Registered: ‎08-14-2013
My Device: Bold 9000
My Carrier: T-Mobile

Re: How to delete a user using the BWS

[ Edited ]

You're absolutly correct. 

Meanwhile I've just set up a local test enviroment, and the response's returnstatus informed me, that it can not delete a user by an e-mail address.

So I created a class that find the user and return its UID and with that the delete request run perfectly.

Thx for the help.