Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Mastering Xamarin.Forms

You're reading from   Mastering Xamarin.Forms Build rich, maintainable, multi-platform, native mobile apps with Xamarin.Forms

Arrow left icon
Product type Paperback
Published in Mar 2018
Publisher
ISBN-13 9781788290265
Length 192 pages
Edition 2nd Edition
Languages
Tools
Arrow right icon
Authors (2):
Arrow left icon
Ed Snider Ed Snider
Author Profile Icon Ed Snider
Ed Snider
Roberto Hernandez Roberto Hernandez
Author Profile Icon Roberto Hernandez
Roberto Hernandez
Arrow right icon
View More author details
Toc

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 data services we might need to write, for example, a service that is responsible for working with log entries in the API. Any class that...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime