2016-12-14 147 views
1

我試着用下面的代碼通過使用Project的FormattedID獲取項目的ObjectID ...但沒有得到任何結果。請讓我知道,哪裏出錯。查詢通過java中的Rally Rest API獲取項目的ObjectID

String projectFormattedID = "EH-HELLO-WORLD"; 
    QueryRequest projectRequest = new QueryRequest("project"); 
    storyRequest.setFetch(new Fetch("ObejctID")); 
    storyRequest.setQueryFilter(new QueryFilter("FormattedID", "=", projectFormattedID)); 
    QueryResponse storyQueryResponse = restApi.query(storyRequest); 
    System.out.println(storyQueryResponse.getResults()); 

回答

0

看起來你在抓取時有一個錯字。它應該是:

storyRequest.setFetch(new Fetch("ObjectID")); 

此外,您還可以隨時通過解析出來的_ref屬性,它總是在所有響應渲染獲取對象ID:

String objectId = Ref.getOidFromRef(storyObject.get("_ref").getAsString()); 
+0

拿到結果時,我改變了查詢過濾器如下: 'storyRequest.setQueryFilter(new QueryFilter(「Name」,「=」,projectFormattedID));'' –

相關問題