Skip to content

Instantly share code, notes, and snippets.

@damirarh
Created June 2, 2013 16:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save damirarh/5693941 to your computer and use it in GitHub Desktop.
Save damirarh/5693941 to your computer and use it in GitHub Desktop.
var http = new HttpClient();
// GET request
var getRequest = "http://hroch486.icpf.cas.cz/cgi-bin/echo.pl?key=value";
var getResponse = await http.GetAsync(getRequest);
var getResult = await getResponse.Content.ReadAsStringAsync();
// POST request
var postUri = new Uri("http://hroch486.icpf.cas.cz/cgi-bin/echo.pl");
var postFields = new Dictionary<string, string>
{
{ "key", "value" }
};
var postContent = new FormUrlEncodedContent(postFields);
var postResponse = await http.PostAsync(postUri, postContent);
var postResult = await postResponse.Content.ReadAsStringAsync();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment