2015-06-15 69 views
1

我試圖從外部應用程序使用API​​密鑰創建集會裏程碑進行憑據授權,但我得到警告「無權創建:里程碑」,每當我運行以下代碼:權限錯誤創建集會裏程碑時使用API​​密鑰

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

我跑了相同的代碼與缺陷和其他拉力賽對象沒有任何問題,我能夠更新現有的里程碑。但是,我仍然無法弄清楚如何創造新的里程碑。

回答

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

     } 
    } 

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

     } 
    } 
+0

這是我在做什麼。我想我只需要在這個項目上擁有更高的權限。看起來很奇怪,我可以在拉力賽中創建里程碑,但沒有權限從外部應用程序進行。 – Laura