使用API​​密钥时权限错误创建集会里程碑 [英] Permissions error creating rally milestone when using API Key

查看:89
本文介绍了使用API​​密钥时权限错误创建集会里程碑的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用用于证书授权的API密钥从外部应用创建集会里程碑,但是每当我运行以下代码时,我都会收到警告未授权创建:里程碑":

I'm trying to create rally milestones from an external app using an API Key for credential authorization, but I get the warning "Not authorized to create: Milestone" whenever I run the following code:

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

我使用相同的代码运行了缺陷和其他拉力赛对象,没有任何问题,并且能够更新现有的里程碑.但是,我仍然不知道如何创建新的里程碑.

I ran the same code with defects and other rally objects without any issues, and I am able to update existing milestones. However, I still can't figure out how to create new milestones.

推荐答案

假定ApiKey属于对预期工作区具有写访问权的用户,则此代码使用

Assuming that ApiKey belongs to a user that has write access to the intended workspace, this code using v3.0.1 of .NET toolkit creates a Milestone in a default project of that workspace:

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

        }
    }

更新:

问题可能与请求的范围有关.在此处中查看如何使用浏览器其余客户端复制和解决此错误.

The issue can be related to the request's scope. See how this error is replicated and resolved using a browser rest client 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);
            }

        }
    }

这篇关于使用API​​密钥时权限错误创建集会里程碑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆