Search code examples
c#.netsdkversionone

VersionOne .NET SDK Creating New Asset


I am trying to create a new Story asset through the V1 API. I am receiving an error:

"Unhandled Exception: VersionOne.SDK.APIClient.ConnectionException:
Error writing to output stream ---> System.Net.WebException: The remote server returned an er ror: (400) Bad Request. ---> VersionOne.SDK.APIClient.APIException:
Violation'Re quired'AttributeDefinition'Super'Story"

I am setting up my connector and creating the asset like so:

        V1Connector connector = V1Connector
            .WithInstanceUrl("xxx")
            .WithUserAgentHeader("NewApp", "1.0")
            .WithAccessToken("xxx")
            .UseOAuthEndpoints()
            .Build();

        IServices services = new Services(connector);

        Oid projectId = services.GetOid("Scope:02284");
        IAssetType storyType = services.Meta.GetAssetType("Story");
        Asset newStory = services.New(storyType, projectId);
        IAttributeDefinition nameAttribute = storyType.GetAttributeDefinition("Name");
        newStory.SetAttributeValue(nameAttribute, "My New Test Story");
        services.Save(newStory); 

The error is given on the last line. I've been trying to figure this out for a while and I haven't come up with a solution. Does anybody have suggestions?

Here is a link to the example I am trying to follow: https://community.versionone.com/VersionOne_Connect/Developer_Library/Get_an_SDK/.NET_SDK/Creating_Assets


Solution

  • Violation'Required'AttributeDefinition'Super'Story exception is being thrown because you are attempting to create a Story asset without populating the required field, 'Super'. Someone in your organization made this a required attribute.

    See your VersionOne project administrator or populate this attribute with a valid value. In order to determine if there are other required fields, do a meta query and any attributes with the '*' next to it is required. As you can see in this png, Name and Scope are my only required attributes.

    enter image description here

    When you look at your meta data, you will see that Super is a relation to an Epic.

    There are two places that you can learn about VersionOne Metadata

    1) http://community.versionone.com/VersionOne_Connect/Developer_Library/Learn_the_API/Meta_API

    2) http://YourVersionOneInstance/help/api

    btw, a Story meta query url has a shape like this

    https://YourVersionOneInstance/meta.v1/Story?xsl=api.xsl