Skip to content

Getting issue creating new Epic under Epic  #65

Open

Description

@bansmani

I am facing some challenges creating assets (Epic) in version one in our sandbox environment using the below example code.

https://community.versionone.com/Digital.ai_Agility_Integrations/Developer_Library/Get_an_SDK/Java_SDK/Creating_Assets

We are getting follow exception (excluding the complete stack trace)

java.lang.RuntimeException: com.versionone.apiclient.exceptions.APIException: Error processing response
Caused by: com.versionone.apiclient.exceptions.APIException: Error processing response
Caused by: com.versionone.apiclient.exceptions.OidException: Invalid OID token: 
Caused by: java.lang.ArrayIndexOutOfBoundsException: Index 1 out of bounds for length 1

My code

Oid id = services.getOid("Epic:" + oid);
IAssetType epicType = services.getMeta().getAssetType("Epic");
Asset newEpic = services.createNew(epicType, id);
newEpic.setAttributeValue(epicType.getAttributeDefinition("Name"), "this is a test epic");
newEpic.setAttributeValue(epicType.getAttributeDefinition("Description"), "auto generated section");
services.save(newEpic);  // <----- throws exception here 

Activity

  1. jallers commented on May 21, 2021

    @jallers
    Contributor

    Could we get more info on what the value of the "oid" variable is above?

    The following code works for me to create an epic underneath another epic. "Epic:7632" is the oid token that refers to a specific Epic in my instance. '7632' is not easily viewable in the interface and is different from the Number (sometimes displayed by the name ID in the interface). A string visible in the interface such as 'E-01128' refers to the Number attribute of the Epic Asset Type and not the number to be used to compose the OID (object identifier) token.

    Oid epicContext = services.getOid("Epic:7632");
    IAssetType epicType = services.getMeta().getAssetType("Epic");
    Asset newEpic = services.createNew(epicType, epicContext);
    newEpic.setAttributeValue(epicType.getAttributeDefinition("Name"), "this is a test epic");
    newEpic.setAttributeValue(epicType.getAttributeDefinition("Description"), "auto generated section");
    services.save(newEpic);

    Creating "Epic:01128" based on the number in "E-01128" would be an invalid OID token. To get the OID from an Asset Number like "E-01128", you would have to query for the asset OID and then proceed with the code above.

    IAssetType epicType = services.getMeta().getAssetType("Epic");
    Query query = new Query(epicType);
    IAttributeDefinition numberAttribute = epicType.getAttributeDefinition("Number");
    FilterTerm numberFilter = new FilterTerm(numberAttribute);
    numberFilter.equal("E-01128");
    query.setFilter(numberFilter);
    Asset epicContext = services.retrieve(query).getAssets()[0];
    
    Asset newEpic = services.createNew(epicType, epicContext.getOid());
    newEpic.setAttributeValue(epicType.getAttributeDefinition("Name"), "this is a test epic");
    newEpic.setAttributeValue(epicType.getAttributeDefinition("Description"), "auto generated section");
    services.save(newEpic);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions