-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSaas C# code.rtf
79 lines (78 loc) · 2.23 KB
/
Saas C# code.rtf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
{\rtf1\ansi\ansicpg1252\cocoartf1348\cocoasubrtf170
{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
{\colortbl;\red255\green255\blue255;}
\paperw11900\paperh16840\margl1440\margr1440\vieww10800\viewh8400\viewkind0
\pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\pardirnatural
\f0\fs24 \cf0 \
using System;\
using System.Collections.Generic;\
using System.Linq;\
using System.Text.RegularExpressions;\
using System.IO;\
\
\
using System.Net;\
\\new line
using System.Text;\
using System.Xml.Linq;\
\
namespace Rextester\
\{\
public class Program\
\{\
public static void Main(string[] args)\
\{\
getCards();\
\
// Console.WriteLine("Hello, world!");\
\}\
\
public static void getCards() \{\
\
String url = "https://anish-support.mingle-api.thoughtworks.com/api/v2/projects/house_build/cards.xml?page=2";\
HttpWebRequest req = (HttpWebRequest) WebRequest.CreateDefault(new Uri(url));\
\
String username = "anishn";\
String password = "anish#13";\
\
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());\
//string content = reader.ReadToEnd();\
//Console.WriteLine(content);\
\
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;\
\
\}\
\
\}\
\}\
\
\}}