Skip to content

Instantly share code, notes, and snippets.

View bfkaradag's full-sized avatar
🦾

Birol Furkan Karadağ bfkaradag

🦾
  • Turkey, Istanbul
View GitHub Profile
@turkdogan
turkdogan / GetRestRequest.cs
Created February 23, 2017 21:26
A Simple Get Request in C#
public static void RequestWeather()
{
const string url = "http://api.geonames.org/weatherJSON?north=44.1&south=-9.9&east=-22.4&west=55.2&username=demo";
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.Method = "GET";
var webResponse = request.GetResponse();
var webStream = webResponse.GetResponseStream();
var responseReader = new StreamReader(webStream);
var response = responseReader.ReadToEnd();