Box.V2.Managers.BoxUsersManager.InviteUserToEnterpriseAsync C# (CSharp) Method

InviteUserToEnterpriseAsync() public method

Invites an existing user to join an Enterprise. The existing user cannot be part of another Enterprise and must already have a Box account. Once invited, the user will receive an email and prompt to accept the invitation within the Box web application. This method requires the "Manage An Enterprise" scope for the enterprise, which can be enabled within your developer console.
public InviteUserToEnterpriseAsync ( BoxUserInviteRequest userInviteRequest, List fields = null ) : Task
userInviteRequest BoxUserInviteRequest BoxUserInviteRequest object.
fields List Attribute(s) to include in the response.
return Task
        public async Task<BoxUserInvite> InviteUserToEnterpriseAsync(BoxUserInviteRequest userInviteRequest, List<string> fields = null)
        {
            userInviteRequest.ThrowIfNull("userInviteRequest")
                .Enterprise.ThrowIfNull("Enterprise").Id.ThrowIfNullOrWhiteSpace("userInviteRequest.Enterprise.Id");
            userInviteRequest.ActionableBy.ThrowIfNull("userInviteRequest.ActionableBy")
               .Login.ThrowIfNullOrWhiteSpace("userInviteRequest.ActionableBy.Login");

            BoxRequest request = new BoxRequest(_config.InviteEndpointUri)
            .Param(ParamFields, fields)
            .Payload(_converter.Serialize(userInviteRequest))
            .Method(RequestMethod.Post);

            IBoxResponse<BoxUserInvite> response = await ToResponseAsync<BoxUserInvite>(request).ConfigureAwait(false);

            return response.ResponseObject;
        }