public async void CreateAsyncTest() { var newCanvas = new SmartCanvas() { Title = "Test Company", Summary = "This is a test company", AutoApprove = true, MetaTags = new List<string>() { "c2" }, ContentProvider = new ContentProvider() { ContentId = "1438266605416", Id = "angular-web-app", UserId = "angular-web-app-user" }, Categories = new List<string>() { "angular-client", "smes", "us-en" }, //JsonExtendedData = ""; Content = "This is content", Attachments = new List<string>() }; await Sut.CreateAsync(newCanvas); }
public async Task CreateAsync(SmartCanvas newCanvas) { using (var client = new HttpClient()) { client.BaseAddress = _apiUrl; client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); client.DefaultRequestHeaders.Add("x-client-id", _clientId); client.DefaultRequestHeaders.Add("x-access-token", _clientToken); // HTTP POST var response = await client.PostAsJsonAsync("application/json", newCanvas); if (response.IsSuccessStatusCode) { //Product product = await response.Content.ReadAsAsync > Product > (); //Console.WriteLine("{0}\t${1}\t{2}", product.Name, product.Price, product.Category); } } }