尝试使用Rally .net REST API创建缺陷,无法设置所有者

时间:2014-06-11 09:15:02

标签: rally

下面是我尝试过的一段代码,我可以设置项目值,但不能设置所有者。

var restAPI = new RallyRestApi("abc@xyz.com", "1234");

String workspaceRef = "/workspace/12345678901";
String projectRef = "/project/9876543210";

DynamicJsonObject toCreate = new DynamicJsonObject();

 //Pass Project
 toCreate["Project"] = projectRef;


 //Pass Owner
 DynamicJsonObject myUser = restAPI.GetCurrentUser();
 string myUserRef = myUser["_ref"];

 toCreate["Owner"] = myUserRef;


 CreateResult createResult = restAPI.Create(workspaceRef, "defect", toCreate);

Alternately I have tried below to set Owner, even this did not work for me. 

String userRef = "/user/11123456225";
toCreate["Owner"] = userRef;

任何帮助都将不胜感激。

1 个答案:

答案 0 :(得分:1)

我刚刚测试this code成功设置了所有者的错误:

 {
            RallyRestApi restApi = new RallyRestApi("user@co.com", "secret", "https://rally1.rallydev.com", "v2.0");
            String workspaceRef = "/workspace/11111"; //use valid workspace OID in your Rally
            String projectRef = "/project/12345";         //use valid project OID in your Rally
            String userRef = "/user/777";
            DynamicJsonObject d = new DynamicJsonObject();
            d["Name"] = "some bug";
            d["Project"] = projectRef;
            d["Owner"] = userRef;

            CreateResult createResult = restApi.Create(workspaceRef, "Defect", d);
            DynamicJsonObject defect = restApi.GetByReference(createResult.Reference, "FormattedID");
            Console.WriteLine(defect["FormattedID"]);

            //update defect
            defect["Description"] = "bad bug";
            OperationResult updateResult = restApi.Update(defect["_ref"], defect);
        }

“无法设置”意味着:您是否收到错误消息,或者在设置其他字段时无声地失败?