Users.CreateUserAsync
Description
Creates a new User of type UserInfo with specified NewUserInfo details inside the connected AI Command Center.
Signature [C#]
Task<UserInfo> CreateUserAsync(NewUserInfo newUserInfo);
Properties
Input
| Parameter | Type | Required / default | Description |
|---|---|---|---|
newUserInfo | NewUserInfo | Required | Specify the details to create new User. |
Output
| Property | Description |
|---|---|
| Task<UserInfo> | Returns newly created user details. |
Remarks
Use CreateTaskAsync API to add new user with specified NewUserInfo from the connected Conrol Room.
Example
C#
public async Task CreateUser()
{
IControlRoomContext context = LoginControlRoom();
try
{
List<Role> roles = new List<Role>();
Role role = new Role();
role.RoleId = 1;
roles.Add(role);
NewUserInfo newUserInfo = new NewUserInfo()
{
UserName = "tester",
FirstName = "ibqa",
LastName = "user",
EmailAddress = "ibqa@vitinfotech.com",
Pwd = "password",
isEnabled = true,
roles = roles
};
UserInfo createUser = await context.Users.CreateUserAsync(newUserInfo);
System.Console.WriteLine("Username: " + createUser.UserName);
}
finally
{
context.Close();
}
}
Connection helper
public IControlRoomContext LoginControlRoom()
{
string RequiredSetting(string name) => Environment.GetEnvironmentVariable(name) ?? throw new InvalidOperationException($"Set {name} before running this example.");
string serverUrl = RequiredSetting("INTELLIBUDDIES_SERVER_URL");
string userName = RequiredSetting("INTELLIBUDDIES_USERNAME");
string password = RequiredSetting("INTELLIBUDDIES_PASSWORD");
string connectionString = $"ServerUrl={serverUrl};UserName={userName};Password={password}";
IControlRoomContext context = new ControlRoomContext(connectionString);
context.Open();
return context;
}
See Get started for namespaces, configuration, and context cleanup, and SDK usage for error handling.