void NewOrders() { Console.WriteLine("===== {0} =====", "POST neworders"); Console.WriteLine(""); Record[] save = new Record[2]; save[0] = new Record { packingslipno = "test1-" + DateTime.Now.ToString("yy-MM-dd"), address1 = "1 Queens Street", address2 = "", suburb = "Auckland Central", city = "Auckland", postcode = "", consignee = "Test 1" }; save[1] = new Record { packingslipno = "test2-" + DateTime.Now.ToString("yy-MM-dd"), address1 = "1 Queens Street", address2 = "", suburb = "Auckland Central", city = "Auckland", postcode = "", consignee = "Test 2" }; HttpResponseMessage response = client.PostAsJsonAsync("v2/neworders", save).Result; // Blocking call! if (response.IsSuccessStatusCode) { // Parse the response body. Blocking! var data = response.Content.ReadAsStringAsync().Result; var lines = JsonConvert.DeserializeObject<List<BatchOrdersResponse>>(data); foreach (var item in lines) { Console.WriteLine(item.packingslipno + " - " + item.result); } } else { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("{0} ({1})", (int)response.StatusCode, response.ReasonPhrase); Console.ForegroundColor = ConsoleColor.White; } }
void NewOrder() { Console.WriteLine("===== {0} =====", "POST neworder"); Console.WriteLine(""); Record save = new Record { packingslipno = "test-" + DateTime.Now.ToString("yy-MM-dd"), address1 = "1 Queens Street", address2 = "", suburb = "Auckland Centrol", city = "Auckland", postcode = "", consignee = "Test," }; HttpResponseMessage response = client.PostAsync("v2/neworder", save, jsonFormatter).Result; // Blocking call! if (response.IsSuccessStatusCode) { // Parse the response body. Blocking! var data = response.Content.ReadAsStringAsync().Result; Console.WriteLine(data); } else { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("{0} ({1})", (int)response.StatusCode, response.ReasonPhrase); Console.ForegroundColor = ConsoleColor.White; } }