Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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();
Console.WriteLine("Response: " + response);
responseReader.Close();
}
@cw-arvindkumar

This comment has been minimized.

Copy link

cw-arvindkumar commented Oct 11, 2019

it will not work if pass # in url.
ex:-http://api.geonames.org/#divBar

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.