In this course you’ll get an in depth look at using HttpClient and HttpClientFactory to integrate with an API, from basic CRUD operations over streaming and compression to dealing with errors and extending HttpClient with custom message handlers.
Applications, ranging from ASP.NET Core web apps over mobile Xamarin apps and Windows apps to Console apps often integrate with an API. For that, HttpClient is the default and best option. But there’s a lot more to using it than just sending a request and reading out the response. In this course, Using HttpClient to Consume APIs in .NET Core, you’ll get an in-depth look at using HttpClient and HttpClientFactory, from the internals over basic CRUD interaction to working with streams and compression. We’ll also cover cancelling requests that are no longer needed.
Additionally, you’ll learn how to use custom message handlers to improve the reliability of your requests and to unit test.
After this course, you'll know the ins and outs of integrating with an API from a variety of application types.
Course Overview Hi everyone. My name is Kevin. Welcome to my course, Using HttpClient to Consume APIs in .NET Core. I'm a Microsoft MVP and a freelance solution architect currently focused on APIs and security. In this course, we are going to learn how to integrate with an API from a .NET Core application. Some of the major topics that we will cover include creating, reading, updating, and deleting resources, improving memory use and performance by working with streams and compression, using HttpClientFactory for HttpClient instance management, and writing custom HttpMessageHandlers. By the end of this course, you will have extensive knowledge on how to integrate with any API from a .NET Core application. Before beginning the course, you should be familiar with C#. I hope you'll join me on this journey to learn how to integrate with an API with the Using HttpClient to Consume APIs in .NET Core course, here at Pluralsight.
Understanding Integration with an API Using HttpClient Hi there, and welcome to the Using HttpClient to Consume APIs in .NET Core course, here at Pluralsight. I'm Kevin, and I'll guide you through it. We're starting the course by looking at the course prerequisites and tooling. Then we'll have a look at the supported platforms, frameworks, and .NET standard versions. You'll notice that the current version of HttpClient actually covers a lot more ground than just .NET Core, and that's thanks to .NET Standard. We'll introduce the demo application next, and we'll learn about different strategies for working with DTO model classes. Lastly, we'll learn how we can tackle integration with HttpClient by having a look at its internals. If you happen to have any questions, the best place to post them is on the Discussion tab on the course page. I check this regularly and like that the questions and answers can help other people out as well. For very short questions that require a quick answer, you can contact me on Twitter, or just follow me if you want to know about my upcoming course, user group events, or are interested in the technology I'm interested in. I mainly tweet regarding ASP.NET Core, security, and APIs these days. Let's have a look at the course prerequisites and tooling.
Handling Common Types of Integration (CRUD) Let's start at the beginning by implementing create, read, update, and delete functionality. I'm Kevin, and I'll guide you through this module. So, in this module, we'll learn how to integrate with an API. In other words, basic functionality. We'll start with getting resources, but we'll also learn how to create, update, and delete a resource. We'll soon see that there's multiple ways to do that, from using shortcuts to directly manipulating the request and headers. So, we'll cover different approaches and learn what the best practice is. Along the way, we'll dive into content negotiation. We'll learn why it's important and how we can work with it. Let's start with getting a resource.
Improving Performance and Memory Use with Streams We want to keep the memory footprint of our application as low as possible and the performance high. Streams can help with that. In this module, we'll learn how. We'll start by learning what streams enable, in other words, the advantages of working with streams. Then we'll learn how we can use that knowledge with HttpClient. In the demos, we'll learn how to read data using streams, how to send data, and we'll test the potential performance improvements. We'll end by looking into compression to further improve performance. Let's dive in by learning about the advantages of using streams.
Unit Testing with HttpClient Custom handlers can be useful for unit testing the parts of your client app that integrates with an API. In this module, we'll learn how. I'm Kevin, and I'll guide you through it. We'll start by learning about use cases where it makes sense to implement HttpClient in such a way that it can be used in unit tests. After that, we'll learn how to do that by writing a custom handler and creating an actual unit test. We'll end up with learning how to use a mocking framework to create mocks of handlers. Let's dive in.