Skip to main content

Roles.CreateRoleAsync

Description

Creates new Role with specified NewRoleInfo details inside the connected Control Room.

Signature [C#]

Task<Role> CreateRoleAsync(NewRoleInfo newRoleInfo)

Properties

Input

PropertyDescription
NewRoleInfoDetails 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 Control Room.

Example

C#
public void CreateRole()
{
IControlRoomContext context = LoginControlRoom();

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 = Task.Run(() => context.Roles.CreateRoleAsync(newRoleInfo)).Result;
Console.WriteLine("RoleName: " + role.RoleName);
}
C#
public IControlRoomContext LoginControlRoom()
{
IControlRoomContext context;
string connectionString;

connectionString = "ServerUrl=https://demo.onnitellibuddies.com;UserName=demoadmin;Password=password";
context = new ControlRoomContext(connectionString);

context.Open();
return context;
}