public async void AddTodo(Todos todo)
        {
            var resource = "todos";
            HttpContent todoContent = new StringContent(JsonConvert.SerializeObject(todo));
            todoContent.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/json");

            var response = await this.httpClient.PostAsync(resource, todoContent);
            Console.WriteLine(await response.Content.ReadAsStringAsync());
        }
        public async void AddTodo(Todos todo)
        {
            var         resource    = "todos";
            HttpContent todoContent = new StringContent(JsonConvert.SerializeObject(todo));

            todoContent.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/json");

            var response = await this.httpClient.PostAsync(resource, todoContent);

            Console.WriteLine(await response.Content.ReadAsStringAsync());
        }
예제 #3
0
        public static void Main(string[] args)
        {
            var consumingApi = new ConsumingJSONPlaceholder();

            Console.WriteLine("Get: ");
            consumingApi.PrintLastTenTodos();

            Console.WriteLine("Put: ");
            consumingApi.UpdateTodosById(200);

            Console.WriteLine("Post: ");
            var todo = new Todos() { UserId = 5, Title = "Must do it.", Completed = false };
            consumingApi.AddTodo(todo);
            Console.ReadLine();
        }
예제 #4
0
        public static void Main(string[] args)
        {
            var consumingApi = new ConsumingJSONPlaceholder();

            Console.WriteLine("Get: ");
            consumingApi.PrintLastTenTodos();

            Console.WriteLine("Put: ");
            consumingApi.UpdateTodosById(200);

            Console.WriteLine("Post: ");
            var todo = new Todos()
            {
                UserId = 5, Title = "Must do it.", Completed = false
            };

            consumingApi.AddTodo(todo);
            Console.ReadLine();
        }