The following script will help you fetch projects and it's associated information from your Mingle SAAS instance.
Note: You don't have to use a HMAC key to authenticate. It works with basic authentication.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using System.IO;
using System.Net;
using System.Text;
using System.Xml.Linq;
namespace Rextester
{
public class Program
{
public static void Main(string[] args)
{
getProject();
}
public static void getProject() {
String url = "https://<org_name>.mingle-api.thoughtworks.com/api/v2/projects.xml";
HttpWebRequest req = (HttpWebRequest) WebRequest.CreateDefault(new Uri(url));
String username = "<username>";
String password = "<password>";
byte[] credentials = Encoding.ASCII.GetBytes(username + ":" + password);
String base64Credentials = Convert.ToBase64String(credentials);
req.Headers.Add("Authorization",
string.Format("Basic {0}", base64Credentials));
StreamReader reader = new StreamReader(req.GetResponse().GetResponseStream());
IEnumerable<Project> projects = (from node in XDocument.Load(reader).Descendants("project")
select new Project
{
Name = node.Element("name").Value,
Identifier = node.Element("identifier").Value,
CreatedAt = node.Element("created_at").Value
});
foreach (var project in projects) {
Console.WriteLine(project);
}
}
class Project {
public String Name;
public String Identifier;
public String CreatedAt;
public override string ToString(){
return Name +" "+ CreatedAt +" "+ Identifier;
}
}
}
}
Comments
0 comments
Please sign in to leave a comment.