Smartsheet.Api.Internal.UserResourcesImpl.AddUser C# (CSharp) Method

AddUser() public method

Add a user To the organization, without sending Email. It mirrors To the following Smartsheet REST API method: POST /Users Exceptions: - IllegalArgumentException : if any argument is null - InvalidRequestException : if there is any problem with the REST API request - AuthorizationException : if there is any problem with the REST API authorization(access token) - ResourceNotFoundException : if the resource can not be found - ServiceUnavailableException : if the REST API service is not available (possibly due To rate limiting) - SmartsheetRestException : if there is any other REST API related error occurred during the operation - SmartsheetException : if there is any other error occurred during the operation

Add a user To the organization

It mirrors To the following Smartsheet REST API method: POST /Users

the Smartsheet exception if any argument is null or empty string if there is any problem with the REST API request if there is any problem with the REST API authorization (access token) if the resource cannot be found if the REST API service is not available (possibly due To rate limiting) if there is any other error during the operation
public AddUser ( User user, bool sendEmail, bool allowInviteAccountAdmin ) : User
user User the user object limited To the following attributes: * Admin * Email * LicensedSheetCreator
sendEmail bool flag indicating whether or not to send a welcome email. Defaults to false.
allowInviteAccountAdmin bool if user is an admin in another organization, setting to true will invite their entire organization.
return User
        public virtual User AddUser(User user, bool? sendEmail, bool? allowInviteAccountAdmin)
        {
            StringBuilder path = new StringBuilder("users");
            IDictionary<string, string> parameters = new Dictionary<string, string>();
            if (sendEmail.HasValue)
            {
                parameters.Add("sendEmail", sendEmail.Value.ToString());
            }
            if (allowInviteAccountAdmin.HasValue)
            {
                parameters.Add("allowInviteAccountAdmin", allowInviteAccountAdmin.Value.ToString());
            }
            return this.CreateResource<User>(QueryUtil.GenerateUrl("users", parameters), typeof(User), user);
        }

Usage Example

Example #1
0
        public virtual void TestAddUserUser()
        {
            server.setResponseBody("../../../TestSDK/resources/addUser.json");

            User user = new User();

            user.Admin                = true;
            user.Email                = "*****@*****.**";
            user.FirstName            = "test425";
            user.LastName             = "test425";
            user.LicensedSheetCreator = true;
            User newUser = userResources.AddUser(user);

            Assert.AreEqual("*****@*****.**", newUser.Email);
            Assert.AreEqual("test425 test425", newUser.Name);
            Assert.AreEqual(false, newUser.Admin);
            Assert.AreEqual(true, newUser.LicensedSheetCreator);
            Assert.AreEqual(3210982882338692L, (long)newUser.ID);
        }
All Usage Examples Of Smartsheet.Api.Internal.UserResourcesImpl::AddUser