Skip to content

Instantly share code, notes, and snippets.

@johnmmoss
Created June 16, 2015 06:59
Show Gist options
  • Save johnmmoss/ff97daa1afcee5644631 to your computer and use it in GitHub Desktop.
Save johnmmoss/ff97daa1afcee5644631 to your computer and use it in GitHub Desktop.
Example Http API Client Request
using (var client = new HttpClient())
{
var serializedBody = JsonConvert.SerializeObject(customerRequest);
var url = string.Format("{0}/{1}", ConfigurationManager.AppSettings["API_URL"], "customer");
var response = await client.PostAsync(url, new StringContent(serializedBody, Encoding.UTF8, "application/json"));
var content = await response.Content.ReadAsStringAsync();
return JsonConvert.DeserializeObject<CustomerResponse>(content);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment