The following script is used to fetch the cards along with the Card Description and Card Type from a project in your Mingle On-Site instance.
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 ConsoleApplication
{
public class Program
{
public static void Main(string[] args)
{
getCards();
}
public static void getCards() {
String url = "http://localhost:8080/api/v2/projects/<project_identifer>/cards.xml";
HttpWebRequest req = (HttpWebRequest) WebRequest.CreateDefault(new Uri(url));
String username = “<username>”;
String password = “<passcode>“;
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());
Console.WriteLine(req);
IEnumerable<Card> cards = (from node in XDocument.Load(reader).Descendants("card")
select new Card
{
Name = node.Element("name").Value,
CardType = node.Element("card_type").Value,
Description = node.Element("description").Value
});
foreach (var card in cards) {
Console.WriteLine(card);
}
}
class Card {
public String Name;
public String CardType;
public String Description;
public override string ToString(){
return Name +" "+ CardType +" "+ Description;
}
console.WriteLine(“Press enter to close.”);
console.ReadLine();
}
}
}
Comments
0 comments
Please sign in to leave a comment.