Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Net;
- using System.IO;
- using System.Text;
- using Newtonsoft.Json;
- using Newtonsoft.Json.Linq;
- namespace c_examples
- {
- class Program
- {
- public const string username = "api-token";
- public const string password = "wu7sglosrwxsq";
- public static String encoded = System.Convert.ToBase64String(System.Text.Encoding.GetEncoding("ISO-8859-1").GetBytes(username+":"+password));
- public static JObject responseToJSON (WebResponse wr)
- {
- var response = (HttpWebResponse)(wr);
- StreamReader sr = new StreamReader(response.GetResponseStream());
- var re = sr.ReadToEnd();
- var dobject = JsonConvert.DeserializeObject(re.ToString());
- var jobj = (JObject) dobject;
- return jobj;
- }
- static void Main(string[] args)
- {
- ServicePointManager.ServerCertificateValidationCallback+= (sender, cert, chain, sslPolicyErrors) =>true;
- var request = (HttpWebRequest) WebRequest.Create("https://dev.azure.com/v-tela/_apis/projects");
- request.Method = "GET";
- request.Headers.Add("Authorization", "Basic "+encoded);
- var response = (HttpWebResponse)request.GetResponse();
- JObject jo = responseToJSON(response);
- Console.WriteLine(jo);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement