使用API​​密钥时权限错误产生的反弹里程碑(Permissions error creating

2019-09-30 08:46发布

我试图从使用凭证授权的API密钥的外部应用程序创建反弹的里程碑,但我得到警告“无权建立:里程碑”每当我运行下面的代码:

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

我跑了有缺陷的和其他集会对象相同的代码没有任何问题,我可以更新现有的里程碑。 但是,我仍然无法弄清楚如何创造新的里程碑。

Answer 1:

假设ApiKey属于具有写权限预期工作区用户,该代码使用V3.0.1 .NET工具包创建在工作区的默认项目的里程碑:

 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);
            }

        }
    }

更新:

这个问题可以涉及到请求的范围。 看到此错误是如何复制和使用浏览器REST客户端解决了这里 。

等效的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);
            }

        }
    }


文章来源: Permissions error creating rally milestone when using API Key