Skip to main content
Version: Current

Users.AssignRoleAsync

Description​

The API assigns the role ID to the specified user ID of the user inside the connected AI Command Center.

Signature [C#]​

Task AssignRoleAsync(int userId, int roleId);

Properties​

Input​

ParameterTypeRequired / defaultDescription
userIdintRequiredSpecify the user ID to assign the specified role.
roleIdintRequiredSpecify the role ID to be assigned to a user.

Remarks​

Use AssignRoleAsync API to assign a role to the specified user ID inside the connected AI Command Center.

Example​

C#
public async Task AssignRole()
{
IControlRoomContext context = LoginControlRoom();
try
{
int userId = 1;
int roleId = 1;
await context.Users.AssignRoleAsync(userId, roleId);
}
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.