Skip to main content
Version: Current

Roles.CreateRoleAsync

Description​

Creates new Role with specified NewRoleInfo details inside the connected AI Command Center.

Signature [C#]​

Task<Role> CreateRoleAsync(NewRoleInfo newRoleInfo);

Properties​

Input​

ParameterTypeRequired / defaultDescription
newRoleInfoNewRoleInfoRequiredDetails to create new Role.

Output​

PropertyDescription
Task<Role>Returns newly created role details.

Remarks​

Use CreateRoleAsync API to create a new Role with provided NewRoleInfo details from connected AI Command Center.

Example​

C#
public async Task CreateRole()
{
IControlRoomContext context = LoginControlRoom();
try
{
string roleName = "RPA User";
string roleDescription = "Role to perform create, edit, view, upload, download, and delete operations on RPA processes.";
List<int> rolePermissions = new List<int>()
{
14,
15,
16,
17,
18,
19
};
NewRoleInfo newRoleInfo = new NewRoleInfo()
{
RoleName = roleName,
Description = roleDescription,
Permissions = rolePermissions
};
Role role = await context.Roles.CreateRoleAsync(newRoleInfo);
Console.WriteLine("RoleName: " + role.RoleName);
}
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.