Код: Выделить всё
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://api.upcloud.com/1.2/account");
string authInfo = "username:password";
authInfo = Convert.ToBase64String(Encoding.Default.GetBytes(authInfo));
request.Headers.Add("Authorization", "Basic " + authInfo);
request.ContentType = "application/json";
request.Method = WebRequestMethods.Http.Get;
request.AllowAutoRedirect = true;
request.Proxy = null;
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Stream stream = response.GetResponseStream();
StreamReader streamreader = new StreamReader(stream);
string s = streamreader.ReadToEnd();
Console.Write(s);
То, что я пытаюсь сделать, это в основном «перевести» приведенный пример Python здесь https://www.upcloud.com/support/getting ... cloud-api/ на C#, но, несмотря на множество предпринятых мной попыток, я до сих пор не нашел решения. Заранее спасибо.
Подробнее здесь: https://stackoverflow.com/questions/511 ... tion-issue
Мобильная версия