使用API​​密钥时创建集会里程碑的权限错误

时间:2015-06-15 21:44:30

标签: permissions rally

我正在尝试使用API​​密钥从外部应用程序创建集会里程碑以进行凭据授权,但每当我运行以下代码时,我都会收到警告“未授权创建:Milestone”:

DynamicJsonObject toCreate = new DynamicJsonObject();
toCreate["Name"] = "test";
CreateResult createResult = restApi.Create("milestone", toCreate);

我使用缺陷和其他拉力赛对象运行相同的代码而没有任何问题,我能够更新现有的里程碑。但是,我仍然无法弄清楚如何创建新的里程碑。

1 个答案:

答案 0 :(得分:0)

假设ApiKey属于对目标工作区具有写访问权限的用户,则使用.NET工具箱v3.0.1的此代码会在该工作区的默认项目中创建里程碑:

 class Program
    {
        static void Main(string[] args)
        {
            RallyRestApi restApi = new RallyRestApi(webServiceVersion: "v2.0");
            String apiKey = "_abc123";
            restApi.Authenticate(apiKey, "https://rally1.rallydev.com", allowSSO: false);
            String workspaceRef = "/workspace/1234";
            try
            {
                DynamicJsonObject m = new DynamicJsonObject();
                m["Name"] = "some milestone";
                CreateResult result = restApi.Create(workspaceRef, "Milestone",m);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }

        }
    }

更新:

该问题可能与请求的范围有关。了解如何使用浏览器休息客户端here复制和解决此错误。

等效的C#代码:

class Program
    {
        static void Main(string[] args)
        {
            RallyRestApi restApi = new RallyRestApi(webServiceVersion: "v2.0");
            String apiKey = "_abc123";
            restApi.Authenticate(apiKey, "https://rally1.rallydev.com", allowSSO: false);
            String projectRef = "/project/2222"; 
            String workspaceRef = "/workspace/1111"; 
            try
            {
                DynamicJsonObject m = new DynamicJsonObject();
                m["Name"] = "some milestone xxxt";
                m["TargetProject"] = projectRef;
                CreateResult result = restApi.Create(workspaceRef, "Milestone",m);
                m = restApi.GetByReference(result.Reference, "FormattedID");
                Console.WriteLine(m["FormattedID"]);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }

        }
    }