假設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);
}
}
}
UPDATE:
該問題可能與請求的範圍有關。瞭解如何使用瀏覽器休息客戶端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);
}
}
}
這是我在做什麼。我想我只需要在這個項目上擁有更高的權限。看起來很奇怪,我可以在拉力賽中創建里程碑,但沒有權限從外部應用程序進行。 – Laura