public bool IsAuthorizeUser(string username, string password) { restApi.Authenticate(username, password, serverUrl, proxy: null, allowSSO: false); if (restApi.AuthenticationState != RallyRestApi.AuthenticationResult.Authenticated) { return(false); } return(true); }
public static RallyRestApi GetRallyRestApi(string userName = "", string password = "", string server = "", string wsapiVersion = "") { if (String.IsNullOrWhiteSpace(userName)) { userName = Settings.Default.UserName; } if (String.IsNullOrWhiteSpace(password)) { password = Settings.Default.Password; } if (String.IsNullOrWhiteSpace(server)) { server = Settings.Default.TestServer; } if (String.IsNullOrWhiteSpace(wsapiVersion)) { wsapiVersion = RallyRestApi.DEFAULT_WSAPI_VERSION; } RallyRestApi api = new RallyRestApi(webServiceVersion: wsapiVersion); api.Authenticate(userName, password, server); return(api); }
static void Main(string[] args) { RallyRestApi restApi = new RallyRestApi(webServiceVersion: "v2.0"); String apiKey = "_abc777"; restApi.Authenticate(apiKey, "https://rally1.rallydev.com", allowSSO: false); String workspaceRef = "/workspace/123"; String projectRef = "/project/134"; DynamicJsonObject badDefect = new DynamicJsonObject(); badDefect["Name"] = "bad defect 2" + DateTime.Now; badDefect["Project"] = projectRef; CreateResult createRequest = restApi.Create(workspaceRef, "Defect", badDefect); badDefect = restApi.GetByReference(createRequest.Reference, "FormattedID", "Project", "State"); Console.WriteLine(badDefect["FormattedID"] + " " + badDefect["Project"]._refObjectName + " " + badDefect["State"]); badDefect["State"] = "Open"; OperationResult updateRequest = restApi.Update(badDefect["_ref"], badDefect); Console.WriteLine("Success? " + updateRequest.Success); Console.WriteLine("updated State: " + badDefect["State"]); }
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[] workspaces = new String[] { "/workspace/12352608129", "/workspace/34900020610" }; foreach (var s in workspaces) { Console.WriteLine(" ______________ " + s + " _________________"); Request typedefRequest = new Request("TypeDefinition"); typedefRequest.Workspace = s; typedefRequest.Fetch = new List <string>() { "ElementName", "Ordinal" }; typedefRequest.Query = new Query("Parent.Name", Query.Operator.Equals, "Portfolio Item"); QueryResult typedefResponse = restApi.Query(typedefRequest); foreach (var t in typedefResponse.Results) { if (t["Ordinal"] > -1) { Console.WriteLine("ElementName: " + t["ElementName"] + " Ordinal: " + t["Ordinal"]); } } } }
/// <summary> /// Authenticate with Rally, with valid credentials. /// </summary> private void LoginToRally() { if (this._rallyApi.AuthenticationState != RallyRestApi.AuthenticationResult.Authenticated) { _rallyApi.Authenticate(this.RallyUserName, this.RallyPassword, RallyConstant.ServerId, null, RallyConstant.AllowSso); } }
public override bool ConnectALMServer() { string username = ALMCore.DefaultAlmConfig.ALMUserName; string password = ALMCore.DefaultAlmConfig.ALMPassword; string serverUrl = ALMCore.DefaultAlmConfig.ALMServerURL; try { restApi.Authenticate(username, password, serverUrl, proxy: null, allowSSO: false); return(true); } catch (Exception ex) { throw ex; } }
private void EnsureRallyIsAuthenticated() { if (this._rallyRestApi.AuthenticationState != RallyRestApi.AuthenticationResult.Authenticated) { _rallyRestApi.Authenticate(this.UserName, this.Password, ServerName, null, RALLY.AllowSso); } }
public void ExampleMethodText() { string username = "******"; string password = "******"; // Initialize the REST API. You can specify a web service version if needed in the constructor. RallyRestApi restApi = new RallyRestApi(); restApi.Authenticate(username, password, "https://preview.rallydev.com", proxy: null, allowSSO: false); //Create an item DynamicJsonObject toCreate = new DynamicJsonObject(); toCreate["Name"] = "My Defect"; CreateResult createResult = restApi.Create("defect", toCreate); //Update the item DynamicJsonObject toUpdate = new DynamicJsonObject(); toUpdate["Description"] = "This is my defect."; OperationResult updateResult = restApi.Update(createResult.Reference, toUpdate); //Get the item DynamicJsonObject item = restApi.GetByReference(createResult.Reference); //Query for items Request request = new Request("defect"); request.Fetch = new List<string>() { "Name", "Description", "FormattedID" }; request.Query = new Query("Name", Query.Operator.Equals, "My Defect"); QueryResult queryResult = restApi.Query(request); foreach (var result in queryResult.Results) { //Process item as needed } //Delete the item OperationResult deleteResult = restApi.Delete(createResult.Reference); }
public static RallyRestApi GetRallyRestApi(string userName = "", string password = "", string server = "", string wsapiVersion = "") { if (String.IsNullOrWhiteSpace(userName)) { userName = Settings.Default.UserName; } if (String.IsNullOrWhiteSpace(password)) { password = Settings.Default.Password; } if (String.IsNullOrWhiteSpace(server)) { server = Settings.Default.TestServer; } if (String.IsNullOrWhiteSpace(wsapiVersion)) { wsapiVersion = RallyRestApi.DEFAULT_WSAPI_VERSION; } RallyRestApi api = new RallyRestApi(webServiceVersion: wsapiVersion); api.Authenticate(userName, password, server); return api; }
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/12352608129"; //String projectRef = "/project/39468725060"; Request request = new Request("Attachment"); request.Workspace = workspaceRef; //request.Project = projectRef; request.Fetch = new List <string>() { "Artifact", "TestCaseResult", "Size", "CreationDate" }; request.Limit = 400; request.Order = "CreationDate Desc"; QueryResult results = restApi.Query(request); foreach (var a in results.Results) { if (a["Artifact"] != null) { Console.WriteLine("Artifact: " + a["Artifact"]["_ref"]); } else if (a["TestCaseResult"] != null) { Console.WriteLine("TestCaseResult: " + a["TestCaseResult"]["_ref"]); } Console.WriteLine("Size: " + a["Size"]); } }
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/123"; String projectRef = "/project/456"; Request request = new Request("PortfolioItem/Feature"); request.Fetch = new List <string>() { "Name", "FormattedID" }; request.Query = new Query("FormattedID", Query.Operator.Equals, "F2356"); QueryResult result = restApi.Query(request); String featureRef = result.Results.First()._ref; Console.WriteLine("found" + featureRef); //create stories try { for (int i = 1; i <= 25; i++) { DynamicJsonObject story = new DynamicJsonObject(); story["Name"] = "story " + i; story["PlanEstimate"] = new Random().Next(2, 10); story["PortfolioItem"] = featureRef; story["Project"] = projectRef; CreateResult createResult = restApi.Create(workspaceRef, "HierarchicalRequirement", story); story = restApi.GetByReference(createResult.Reference, "FormattedID"); Console.WriteLine("creating..." + story["FormattedID"]); } //read stories DynamicJsonObject feature = restApi.GetByReference(featureRef, "UserStories"); Request storiesRequest = new Request(feature["UserStories"]); storiesRequest.Fetch = new List <string>() { "FormattedID", "PlanEstimate" }; storiesRequest.Limit = 1000; QueryResult storiesResult = restApi.Query(storiesRequest); int storyCount = 0; foreach (var userStory in storiesResult.Results) { Console.WriteLine(userStory["FormattedID"] + " " + userStory["PlanEstimate"]); storyCount++; } Console.WriteLine(storyCount); } catch (Exception e) { Console.WriteLine(e); } }
public static void Initialize(string userName, string password, string server, string wsapiVersion = "") { if (String.IsNullOrWhiteSpace(wsapiVersion)) { wsapiVersion = RallyRestApi.DEFAULT_WSAPI_VERSION; } _rally = new RallyRestApi(webServiceVersion: wsapiVersion); _rally.Authenticate(userName, password, server); }
public static bool Login(string user, string password) { RestApi = new RallyRestApi(); RestApi.Authenticate(user, password, "https://rally1.rallydev.com", proxy: null, allowSSO: false); if (RestApi != null) { return(true); } return(false); }
public static QueryResult RequetQuery(string artifact, Query query) { var restApi = new RallyRestApi(); restApi.Authenticate(ConfigurationManager.AppSettings["rallyUser"], ConfigurationManager.AppSettings["rallyPass"], "https://rally1.rallydev.com", proxy: null, allowSSO: false); Request request = new Request(artifact); request.Query = query; return(restApi.Query(request)); }
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/1011574887"; //non-default workspace of the user String projectRef = "/project/1791269111"; //a non-default project of the user (inside the workspace above) try { //create testset DynamicJsonObject myTestSet = new DynamicJsonObject(); myTestSet["Name"] = "important set " + DateTime.Now; myTestSet["Project"] = projectRef; CreateResult createTestSet = restApi.Create(workspaceRef, "TestSet", myTestSet); myTestSet = restApi.GetByReference(createTestSet.Reference, "FormattedID", "Project"); Console.WriteLine(myTestSet["FormattedID"] + " " + myTestSet["Project"]._refObjectName); //find current iteration Request iterationRequest = new Request("Iteration"); iterationRequest.Project = projectRef; iterationRequest.ProjectScopeDown = false; iterationRequest.ProjectScopeUp = false; iterationRequest.Fetch = new List <string>() { "ObjectID", "Name" }; iterationRequest.Query = new Query("(StartDate <= Today)").And(new Query("(EndDate >= Today)")); QueryResult queryResults = restApi.Query(iterationRequest); if (queryResults.TotalResultCount > 0) { Console.WriteLine(queryResults.Results.First()["Name"] + " " + queryResults.Results.First()["ObjectID"]); myTestSet["Iteration"] = queryResults.Results.First()._ref; OperationResult updateResult = restApi.Update(myTestSet["_ref"], myTestSet); } else { Console.WriteLine("No current iterations"); } } catch (Exception e) { Console.WriteLine(e); } }
public Rally(string username, string password) { string serverUrl = "https://rally1.rallydev.com/"; restApi = new RallyRestApi(); restApi.Authenticate(username, password, serverUrl, proxy: null, allowSSO: false); if (restApi.AuthenticationState != RallyRestApi.AuthenticationResult.Authenticated) { IsAuthenticated = false; } else { IsAuthenticated = true; } }
public void AuthenticateWithRallyServer() { //Arrange RallyRestApi api = new RallyRestApi(); //Act if (api.AuthenticationState != RallyRestApi.AuthenticationResult.Authenticated) { api.Authenticate("*****@*****.**", "iYmcmb24", "https://rally1.rallydev.com", null, false); } //Assert Assert.AreEqual("Authenticated", api.AuthenticationState.ToString()); api.Logout(); Assert.AreEqual("NotAuthorized", api.AuthenticationState.ToString()); }
public void ExampleMethodText() { string username = "******"; string password = "******"; // Initialize the REST API. You can specify a web service version if needed in the constructor. RallyRestApi restApi = new RallyRestApi(); restApi.Authenticate(username, password, "https://preview.rallydev.com", proxy: null, allowSSO: false); //Create an item DynamicJsonObject toCreate = new DynamicJsonObject(); toCreate["Name"] = "My Defect"; CreateResult createResult = restApi.Create("defect", toCreate); //Update the item DynamicJsonObject toUpdate = new DynamicJsonObject(); toUpdate["Description"] = "This is my defect."; OperationResult updateResult = restApi.Update(createResult.Reference, toUpdate); //Get the item DynamicJsonObject item = restApi.GetByReference(createResult.Reference); //Query for items Request request = new Request("defect"); request.Fetch = new List <string>() { "Name", "Description", "FormattedID" }; request.Query = new Query("Name", Query.Operator.Equals, "My Defect"); QueryResult queryResult = restApi.Query(request); foreach (var result in queryResult.Results) { //Process item as needed } //Delete the item OperationResult deleteResult = restApi.Delete(createResult.Reference); }
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/32904827032"; try { //create story DynamicJsonObject myStory = new DynamicJsonObject(); myStory["Name"] = "another story " + DateTime.Now; myStory["Project"] = projectRef; CreateResult createStory = restApi.Create(workspaceRef, "HierarchicalRequirement", myStory); myStory = restApi.GetByReference(createStory.Reference, "FormattedID", "Project"); //update story myStory["Description"] = "updated " + DateTime.Now; myStory["c_CustomString"] = "abc123"; Console.WriteLine("--------------------"); Console.WriteLine(myStory["FormattedID"]); OperationResult updateResult = restApi.Update(myStory["_ref"], myStory); //create tasks for (int i = 1; i <= 3; i++) { DynamicJsonObject myTask = new DynamicJsonObject(); myTask["Name"] = "task " + i + DateTime.Now; myTask["State"] = "In-Progress"; myTask["WorkProduct"] = myStory["_ref"]; CreateResult createTask = restApi.Create(workspaceRef, "Task", myTask); myTask = restApi.GetByReference(createTask.Reference, "FormattedID", "Owner", "State"); Console.WriteLine(myTask["FormattedID"]); } } catch (Exception e) { Console.WriteLine(e); } }
public ApiClass(string username, string password, string host) { restApi = new RallyRestApi(); try { restApi.Authenticate(username, password, host, proxy: null, allowSSO: false); } catch (UriFormatException ex) { var confirmResult = MessageBox.Show("Wrong URL for server", "Error connection", MessageBoxButtons.OK); if (confirmResult == DialogResult.OK) { System.Windows.Forms.Application.Exit(); System.Environment.Exit(0); } } catch (RallyUnavailableException ex) { var confirmResult = MessageBox.Show("Connection was not opened", "Error connection", MessageBoxButtons.OK); if (confirmResult == DialogResult.OK) { System.Windows.Forms.Application.Exit(); System.Environment.Exit(0); } } catch (Exception ex) { System.Windows.Forms.Application.Exit(); System.Environment.Exit(0); } }
static void Main(string[] args) { string username = "******"; string password = "******"; string serverUrl = "https://rally1.rallydev.com"; RallyRestApi restApi = new RallyRestApi(); restApi.Authenticate(username, password, serverUrl, proxy: null, allowSSO: false); Request request = new Request("project"); request.Fetch = new List <string>() { "Name", "Description", "FormattedID" }; request.Query = new Query("Name", Query.Operator.Contains, "ahm"); QueryResult queryResult = restApi.Query(request); foreach (var result in queryResult.Results) { string aa = result.ToString(); } }
public ObservableList <RallyTestPlan> GetRallyTestPlansByProject(string RallyServerUrl, string RallyUserName, string RallyPassword, string RallyProject, string solutionFolder, string projName) { ObservableList <RallyTestPlan> rallyTestPlanList = new ObservableList <RallyTestPlan>(); RallyRestApi restApi = new RallyRestApi(); restApi.Authenticate(RallyUserName, RallyPassword, RallyServerUrl, proxy: null, allowSSO: false); if (restApi.AuthenticationState == RallyRestApi.AuthenticationResult.Authenticated) { DynamicJsonObject sub = restApi.GetSubscription("Workspaces"); Request wRequest = new Request(sub["Workspaces"]); wRequest.Limit = 1000; int projectId = 0; QueryResult queryWSResult = restApi.Query(wRequest); foreach (var result in queryWSResult.Results) { Request projectsRequest = new Request(result["Projects"]); projectsRequest.Fetch = new List <string>() { "Name", "ObjectID" }; projectsRequest.Limit = 10000; QueryResult queryProjectResult = restApi.Query(projectsRequest); foreach (var p in queryProjectResult.Results) { if (Convert.ToString(p["Name"]) == projName) { int.TryParse(Convert.ToString(p["ObjectID"]), out projectId); break; } } } if (projectId > 0) { //Query for items Request request = new Request("testset"); var projectRef = "/project/" + projectId; request.Query = new Query("Project", Query.Operator.Equals, projectRef); QueryResult queryTestSetResult = restApi.Query(request); foreach (var result in queryTestSetResult.Results) { RallyTestPlan plan = new RallyTestPlan(); int testSetId = 0; int.TryParse(Convert.ToString(result["ObjectID"]), out testSetId); if (testSetId > 0) { plan.Name = Convert.ToString(result["Name"]); plan.RallyID = Convert.ToString(result["ObjectID"]); plan.Description = Convert.ToString(result["Description"]); plan.CreatedBy = Convert.ToString(result["Owner"]["_refObjectName"]); plan.CreationDate = Convert.ToDateTime(result["CreationDate"]); plan.TestCases = new ObservableList <RallyTestCase>(); } rallyTestPlanList.Add(plan); } } } return(rallyTestPlanList); }
public RallyTestPlan GetRallyTestPlanFullData(string RallyServerUrl, string RallyUserName, string RallyPassword, string RallyProject, RallyTestPlan testPlan) { Mouse.OverrideCursor = System.Windows.Input.Cursors.Wait; RallyTestPlan plan = new RallyTestPlan(); RallyRestApi restApi = new RallyRestApi(); restApi.Authenticate(RallyUserName, RallyPassword, RallyServerUrl, proxy: null, allowSSO: false); if (restApi.AuthenticationState == RallyRestApi.AuthenticationResult.Authenticated) { DynamicJsonObject sub = restApi.GetSubscription("Workspaces"); Request wRequest = new Request(sub["Workspaces"]); wRequest.Limit = 1000; int projectId = 0; QueryResult queryWSResult = restApi.Query(wRequest); foreach (var result in queryWSResult.Results) { Request projectsRequest = new Request(result["Projects"]); projectsRequest.Fetch = new List <string>() { "Name", "ObjectID" }; projectsRequest.Limit = 10000; QueryResult queryProjectResult = restApi.Query(projectsRequest); foreach (var p in queryProjectResult.Results) { if (Convert.ToString(p["Name"]) == RallyProject) { int.TryParse(Convert.ToString(p["ObjectID"]), out projectId); break; } } } if (projectId > 0) { //Query for items Request request = new Request("testset"); var projectRef = "/project/" + projectId; request.Query = new Query("Project", Query.Operator.Equals, projectRef); QueryResult queryTestSetResult = restApi.Query(request); foreach (var result in queryTestSetResult.Results) { int testSetId = 0; int.TryParse(Convert.ToString(result["ObjectID"]), out testSetId); if (testSetId > 0 && testPlan.RallyID == Convert.ToString(result["ObjectID"])) { plan.Name = Convert.ToString(result["Name"]); plan.RallyID = Convert.ToString(result["ObjectID"]); plan.Description = Convert.ToString(result["Description"]); plan.CreatedBy = Convert.ToString(result["Owner"]["_refObjectName"]); plan.CreationDate = Convert.ToDateTime(result["CreationDate"]); plan.TestCases = new ObservableList <RallyTestCase>(); Request reqTestCase = new Request("testcase"); var testSetIdRef = "/testset/" + testSetId; reqTestCase.Query = new Query("TestSets", Query.Operator.Equals, testSetIdRef); QueryResult queryTestcaseResult = restApi.Query(reqTestCase); foreach (var testCaseResult in queryTestcaseResult.Results) { string name = Convert.ToString(testCaseResult["Name"]); string id = Convert.ToString(testCaseResult["ObjectID"]); string desc = Convert.ToString(testCaseResult["Description"]); string owner = Convert.ToString(testCaseResult["Owner"]["_refObjectName"]); DateTime createDate = Convert.ToDateTime(testCaseResult["CreationDate"]); RallyTestCase tcase = new RallyTestCase(name, id, desc, owner, createDate); string scriptdesc = Convert.ToString(testCaseResult["ValidationInput"]); RallyTestStep script = new RallyTestStep("Test Step 1", string.Empty, scriptdesc, owner); tcase.TestSteps.Add(script); plan.TestCases.Add(tcase); } } } } } Mouse.OverrideCursor = null; return(plan); }
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/1011574887"; String projectRef = "/project/1791269111"; String userName = "******"; try { Request storyRequest = new Request("hierarchicalrequirement"); storyRequest.Workspace = workspaceRef; storyRequest.Project = projectRef; storyRequest.Fetch = new List <string>() { "FormattedID" }; storyRequest.Query = new Query("FormattedID", Query.Operator.Equals, "US2917"); QueryResult queryResult = restApi.Query(storyRequest); var storyObject = queryResult.Results.First(); String storyReference = storyObject["_ref"]; Request userRequest = new Request("user"); userRequest.Fetch = new List <string>() { "UserName" }; userRequest.Query = new Query("UserName", Query.Operator.Equals, userName); QueryResult queryUserResults = restApi.Query(userRequest); DynamicJsonObject user = new DynamicJsonObject(); user = queryUserResults.Results.First(); String userRef = user["_ref"]; String imageFilePath = "C:\\images\\"; String imageFileName = "rally.png"; String fullImageFile = imageFilePath + imageFileName; Image myImage = Image.FromFile(fullImageFile); string imageBase64String = ImageToBase64(myImage, System.Drawing.Imaging.ImageFormat.Png); var imageNumberBytes = Convert.FromBase64String(imageBase64String).Length; Console.WriteLine("Image size: " + imageNumberBytes); DynamicJsonObject myAttachmentContent = new DynamicJsonObject(); myAttachmentContent["Content"] = imageBase64String; CreateResult myAttachmentContentCreateResult = restApi.Create(workspaceRef, "AttachmentContent", myAttachmentContent); String myAttachmentContentRef = myAttachmentContentCreateResult.Reference; Console.WriteLine(myAttachmentContentRef); DynamicJsonObject myAttachment = new DynamicJsonObject(); myAttachment["Artifact"] = storyReference; myAttachment["Content"] = myAttachmentContentRef; myAttachment["Name"] = "rally.png"; myAttachment["Description"] = "Attachment Desc"; myAttachment["ContentType"] = "image/png"; myAttachment["Size"] = imageNumberBytes; myAttachment["User"] = userRef; CreateResult myAttachmentCreateResult = restApi.Create(workspaceRef, "Attachment", myAttachment); List <string> createErrors = myAttachmentContentCreateResult.Errors; for (int i = 0; i < createErrors.Count; i++) { Console.WriteLine(createErrors[i]); } String myAttachmentRef = myAttachmentCreateResult.Reference; Console.WriteLine(myAttachmentRef); } catch (Exception e) { Console.WriteLine(e); } }