2013-07-09 78 views

回答

0

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

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

它採用拉力賽REST的API-1.0.7.jar,這與最新的WS API 2.0版

工作如果您使用的拉力賽REST的API-1.0.6.jar應該還是使用拉力賽REST的API-1.0.6.jar時,如果不指定版本或空:工作只要WS API版本中正確設置代碼,例如:

String wsapiVersion = "1.43"; 

它將返回DirectChildrenCount指定低於1.39的版本。在1.39中引入了DirectChildrenCount。

如果你使用的是rally-rest-api-1.0.7.jar,它默認爲2.0版的WS API,所以下面的代碼將工作,並且即使沒有設置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 = "[email protected]"; 
    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")); 
    } 
相關問題