无法使用Java API在版本1中创建新资产

时间:2017-08-16 16:01:24

标签: java versionone

您好我在尝试使用Version One Java SDK开发自动化时面临问题,而且我无法在项目下创建新项目。代码每次都失败并出现以下异常:

com.versionone.apiclient.exceptions.APIException: Error processing response
    at com.versionone.apiclient.Services.save(Services.java:337)
    at com.versionone.apiclient.Services.save(Services.java:290)
    at yia.vone.connect.YodV1Connector.createPortfolioItem(YodV1Connector.java:46)
    at yia.vone.connect.YodV1Connector.main(YodV1Connector.java:55)
Caused by: com.versionone.apiclient.exceptions.OidException: Invalid OID token: 
    at com.versionone.Oid.fromToken(Oid.java:184)
    at com.versionone.apiclient.Services.getOid(Services.java:252)
    at com.versionone.apiclient.Services.parseSaveAssetNode(Services.java:552)
    at com.versionone.apiclient.Services.save(Services.java:335)
    ... 3 more
Caused by: java.lang.ArrayIndexOutOfBoundsException: 1
    at com.versionone.Oid.fromToken(Oid.java:177)
    ... 6 more

代码如下:

public static void createPortfolioItem(V1Connector connector) throws V1Exception {
    IServices services = new Services(connector);
    Oid projectId = services.getOid("Scope:244424");
    System.out.println(projectId.getToken());

    IAssetType epicType = services.getMeta().getAssetType("Epic");
    System.out.println(epicType.getToken());

    Asset newItem = services.createNew(epicType, projectId);
    System.out.println(newItem.getOid().getToken());

    IAttributeDefinition nameAttribute = epicType.getAttributeDefinition("Name");
    newItem.setAttributeValue(nameAttribute, "Internal Test X");

    // Exception occurs here
    services.save(newItem);

    System.out.println(newItem.getOid().getToken());
    System.out.println(newItem.getAttribute(
        epicType.getAttributeDefinition("Scope")).getValue());
    System.out.println(newItem.getAttribute(nameAttribute).getValue());
}

该行发生异常:

services.save(newItem);

请帮忙。

0 个答案:

没有答案