Skip to main content

EnterpriseVariable.CreateVariableAsync

Description

The API creates a new Enterprise Variable with provided details inside the connected Control Room. You can find the newly created Enterprise Variable in Control Room under the Assets\Enterprise Variables section.

Signature [C#]

Task<EnterpriseVariable> CreateVariableAsync(NewVariable newVariable)

Properties

Input

PropertyDescription
NewVariableDetails of the variable to be created.

Output

PropertyDescription
Task<EnterpriseVariable>Returns newly created enterprise variable object.

Remarks

Use CreateVariableAsync API to create a new enterprise variable inside the connected Control Room.

Example

C#
public void CreateEnterpriseVariable()
{
IControlRoomContext context = LoginControlRoom("RegularBuild", "BasicAuth");

NewVariable newVariable = new NewVariable()
{
Name = "TestEvar",
Value = "3.14",
UserName = null,
Password = null,
Description = "Represents Pi value",
TypeID = 2,
ScopeID = 2,
IsEncrypted = true,
OwnerId = 1
};

EnterpriseVariable enterpriseVariable = Task.Run(() => context.EnterpriseVariables.CreateVariableAsync(newVariable)).Result;
System.Console.WriteLine("Enterprise Variable Name is " + enterpriseVariable.Name);
}
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;
}