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

Permissions error creating rally milestone when using API Key

我正在尝试使用 API 密钥从外部应用程序创建拉力赛里程碑进行凭据授权,但每当我 运行 以下代码时,我都会收到警告 "Not authorized to create: Milestone":

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

我 运行 有缺陷的相同代码和其他集会对象没有任何问题,我能够更新现有的里程碑。但是,我仍然不知道如何创建新的里程碑。

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

        }
    }

更新:

问题可能与请求的范围有关。查看如何使用浏览器 rest 客户端 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);
            }

        }
    }