Creating a base HTTP service
In order for an app to communicate with an API via HTTP, it needs an HTTP library. Since we are using .NET and C# to build a Xamarin.Forms app, we can leverage a library within the .NET Framework, called System.Net.Http.HttpClient. The .NET HttpClient provides a mechanism to send and receive data via standard HTTP methods, such as GET and POST.
Continuing to keep separation and abstraction key to our app architecture, we want to keep the specific logic related to the HttpClient separate from the rest of the app. In order to do this, we will write a base service class in our core library that will be responsible for handling HTTP communications in a generic way. This provides a building block for any domain-specific ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access