Created
June 16, 2015 06:59
-
-
Save johnmmoss/ff97daa1afcee5644631 to your computer and use it in GitHub Desktop.
Example Http API Client Request
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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