Skip to main content
System StatusContact Support
VersionOne Community

Creating Assets

Overview

When you create a new asset with the .NET SDK, you need to specify the context of another asset that will be the parent. For example, if you create a new Story asset you can specify which Scope (project) it should be created in.

Prior to creating an asset in VersionOne, you must first instantiate a V1Connector and Services object:

V1Connector connector = V1Connector
    .WithInstanceUrl("<Server Base URI>")
    .WithUserAgentHeader("AppName", "1.0")
    .WithAccessToken("1.rWM8lKLk+PnyFxkEWVX5Kl2u6Jk=")
    .Build();
   
IServices services = new Services(connector);

In versions of the SDK prior to the 15.0.0.0 release, you would also have to instantiate a connector for the MetaModel object. However, starting with the 15.0.0.0 release, that is no longer necessary. The MetaModel object is now available from the Meta property of the Services object.

Creating a New Asset

This example shows how to create a Story asset in the context of a Scope with ID 1012:

Oid projectId = services.GetOid("Scope:1012");
IAssetType storyType = services.Meta.GetAssetType("Story");
Asset newStory = services.New(storyType, projectId);
IAttributeDefinition nameAttribute = storyType.GetAttributeDefinition("Name");
newStory.SetAttributeValue(nameAttribute, "My New Story");
services.Save(newStory);
 
Console.WriteLine(newStory.Oid.Token);
Console.WriteLine(newStory.GetAttribute(storyType.GetAttributeDefinition("Scope")).Value);
Console.WriteLine(newStory.GetAttribute(nameAttribute).Value);

/***** OUTPUT *****
Story:1094
Scope:1012
My New Story
******************/
  • Was this article helpful?