Ejemplo n.º 1
0
        public async Task Execute()
        {
            while (true)
            {
                //Get the html code from the google home page
                await httpClient.Get("http://www.google.com");

                //Asynchronously, get the json from jsonplaceholder and serialize it.
                httpClient.Get <List <Todo> >("https://jsonplaceholder.typicode.com/todos/", options =>
                {
                    options.RequestMediaType = new JsonHttpMediaType();
                    options.AddHeader("Authorization", "Bearer <token>");
                    options.QueryStrings.Add("name", "John Doe");
                }).Subscribe();

                tmdbConsumer.ListMovies().Subscribe();

                httpClient.Post <Identifiable>(@"https://jsonplaceholder.typicode.com/posts", new Post()
                {
                    Title  = "Foo",
                    Body   = "Bar",
                    UserId = 3
                }).Subscribe();

                await httpClient.Post(@"https://postman-echo.com/post");
            }
        }
Ejemplo n.º 2
0
        public async void TestPostWithJson()
        {
            var postWithId = await http.Post <Identifiable>(@"https://jsonplaceholder.typicode.com/posts", new Post()
            {
                Title  = "Foo",
                Body   = "Bar",
                UserId = 3
            });

            Assert.NotNull(postWithId);
        }