TheTobruk
0
Q:

how make a post request c#

using System.Net.Http;
private static readonly HttpClient client = new HttpClient();
var values = new Dictionary<string, string>
{
    { "thing1", "hello" },
    { "thing2", "world" }
};
var content = new FormUrlEncodedContent(values);
var response = await client.PostAsync("http://www.example.com/recepticle.aspx", content);
var responseString = await response.Content.ReadAsStringAsync();
2
 //You can aquire RestSharp from Nuget package manager
  RestClient restClient = 
  new RestClient(string.Format("{0}/myservice/api/endpoint", "https://exampledomain.com:88"));
  RestRequest request = new RestRequest(Method.POST);
  request.RequestFormat = DataFormat.Json;
  request.AddJsonBody(data); //data is C# model for post request
  request.AddHeader("Accept", "application/pdf");
  var result = restClient.Execute(request);
0

New to Communities?

Join the community