Skip to content

Instantly share code, notes, and snippets.

@jackphilippi
Last active November 15, 2018 06:17
Show Gist options
  • Save jackphilippi/3953305a605c18538cf6d22c7b8d7630 to your computer and use it in GitHub Desktop.
Save jackphilippi/3953305a605c18538cf6d22c7b8d7630 to your computer and use it in GitHub Desktop.
using System.Net.Http;
// Create a new HTTP client which we will use to send the request
private static readonly HttpClient client = new HttpClient();
// Create a dictionary with the value(s) you want to send
var values = new Dictionary<string, string>
{
{ "firstNumber", 123 },
{ "secondNumber", 456 },
};
// Convert the dictionary above into the correct format (url encoded) to be sent over the network
var content = new FormUrlEncodedContent(values);
// Send the url encoded data via POST to a URL or IP address
var response = await client.PostAsync("https://testibrahim.free.beeceptor.com", content);
// Read the data that the URL or IP address responded with
var responseString = await response.Content.ReadAsStringAsync();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment