2

我尝试将讨论添加到用户故事。部分代码

        QueryResponse storyQueryResponse = restApi.query(storyRequest);
        JsonObject storyJsonObject = storyQueryResponse.getResults().get(0).getAsJsonObject();
        String storyRef = storyJsonObject.get("_ref").toString();
        System.out.println("Ref: " + storyRef);

        Ref ref = new Ref();
        System.out.println(ref.getOidFromRef(storyRef));
        System.out.println(ref.isRef(storyRef));

        createDis.addProperty("Artifact", ref.getOidFromRef(storyRef));
        createDis.addProperty("Text", "Java-Java-Java-Java-Java-Java-Java-Java-Java-Java-Java-Java");
        CreateRequest createRequest = new CreateRequest("ConversationPost", createDis);
        CreateResponse createResponse = restApi.create(createRequest);

System.out.println("Ref: " + storyRef) return Ref: " https://rally1.rallydev.com/slm/webservice/v2.0/hierarchicalrequirement/13097497257 "

ref.getOidFromRef(storyRef) 返回 NULL ref.isRef(storyRef) 返回 FALSE

为什么???

4

1 回答 1

0

此行无效,并导致您的 ref 在其周围有一组额外的引号:

String storyRef = storyJsonObject.get("_ref").toString();

将其更改为此应该可以正常工作:

String storyRef = storyJsonObject.get("_ref").getAsString();

始终使用 getAs 方法而不是 toString。

于 2013-08-23T15:08:35.270 回答