Created
February 23, 2017 21:26
-
-
Save turkdogan/1b972399aa7fdf0796335d0cba58166e to your computer and use it in GitHub Desktop.
A Simple Get Request in C#
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | |
Console.WriteLine("Response: " + response); | |
responseReader.Close(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
it will not work if pass # in url.
ex:-http://api.geonames.org/#divBar