I’m trying to write some C# code to utilize the VersionOne SDK to create a Defect asset. I’ve queried our system and have identified the required attributes:
Defect derives from PrimaryWorkitem
- Description : LongText
- Name : Text
- Parent : Relation to Theme — reciprocal of Children
- Priority : Relation to WorkitemPriority — reciprocal of PrimaryWorkitems
- Scope : Relation to Scope — reciprocal of Workitems
- Source : Relation to StorySource — reciprocal of PrimaryWorkitems
- Status : Relation to StoryStatus — reciprocal of PrimaryWorkitems
- Team : Relation to Team — reciprocal of Workitems
Some of the values are obvious while others are somewhat abstract. For example, I’m not sure what to specify for the “Parent” attribute or the “Scope”. The documentation for creating an Asset with the SDK is pretty sparse. I can’t seem to find any code examples for using the SDK. At the moment, my code returns an exception:
The remote server returned an error: (400) Bad Request Violation'Required'AttributeDefinition'Parent'Defect
And, here’s the code I’m using at the moment:
static void AddV1Record(List<V1WerRecord> records)
{
V1Connector connector = V1Connector
.WithInstanceUrl(VersionOneURL)
.WithUserAgentHeader("VersionOneUpdate", "1.0")
.WithUsernameAndPassword(VersionOneId, VersionOnePwd)
.Build();
IServices services = new Services(connector);
Oid projectId = services.GetOid("Scope:0");
IAssetType storyType = services.Meta.GetAssetType("Defect");
Asset newDefect = services.New(storyType, projectId);
IAttributeDefinition descAttribute = storyType.GetAttributeDefinition("Description");
newDefect.SetAttributeValue(descAttribute, "My New Defect");
IAttributeDefinition nameAttribute = storyType.GetAttributeDefinition("Name");
newDefect.SetAttributeValue(nameAttribute, "My Name");
services.Save(newDefect);
I understand the error is caused by not specifying all of the required attributes. I’m at a loss for what to specify for some of the attributes: Parent, Scope, etc.
Does anyone know of better documentation that explains using the SDK to create an Asset? Are there any good SDK examples/sample code available?