簡體   English   中英

使用Rally Java Rest API,如何獲取DirectChildrenCount?

[英]Using the Rally Java Rest API, how do I get DirectChildrenCount?

我似乎能夠獲得除此屬性以外的所有其他屬性。 查詢此屬性時,在控制台中得到DirectChildrenCount:null。

假設您獲取DirectChildrenCount,接下來要驗證的是您正在使用的Java Rally REST takeit的版本以及您在代碼中指定的WS API版本。

這是一個打印出DirectChildrenCount的代碼示例。

它使用了rally-rest-api-1.0.7.jar,該版本可與最新的WS API v2.0一起使用

如果您使用的是rally-rest-api-1.0.6.jar,則只要代碼中正確設置了WS API版本,它就應該可以正常工作,例如:

String wsapiVersion = "1.43";

如果您未指定版本或指定的版本低於1.39,則在使用rally-rest-api-1.0.6.jar時將返回DirectChildrenCount:null。 DirectChildrenCount在1.39中引入。

如果使用的是rally-rest-api-1.0.7.jar,則默認使用WS API的v2.0,因此即使未在代碼中設置WS API版本,下面的代碼也可以使用,並且將返回DirectChildrenCount。

public static void main(String[] args) throws URISyntaxException, IOException {

    // Create and configure a new instance of RallyRestApi

    String host = "https://rally1.rallydev.com";
    String username = "user@domain.com";
    String password = "secret";
    String wsapiVersion = "v2.0";
        String workspaceRef = "/workspace/1111";
    String projectRef = "/project/2222"; 
    String applicationName = "DirectChildrenCount";


        RallyRestApi restApi = new RallyRestApi(
                new URI(host),
                username,
                password);
        restApi.setWsapiVersion(wsapiVersion);
        restApi.setApplicationName(applicationName);   


        QueryRequest storyRequest = new QueryRequest("HierarchicalRequirement");
        storyRequest.setFetch(new Fetch("Name","DirectChildrenCount"));
        storyRequest.setWorkspace(workspaceRef);
        storyRequest.setQueryFilter(new QueryFilter("FormattedID", "=", "US16"));

        QueryResponse storyQueryResponse = restApi.query(storyRequest);
        JsonObject storyJsonObject = storyQueryResponse.getResults().get(0).getAsJsonObject();
        System.out.println(storyJsonObject.get("Name") + " DirectChildrenCount: " + storyJsonObject.get("DirectChildrenCount"));
    }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM