Hello,
Welcome to Microsoft Q&A!
A similar class in c# is HttpClient Class, which provides a class for sending HTTP requests and receiving HTTP responses from a resource identified by a URI.
An examples:
// HttpClient is intended to be instantiated once per application, rather than per-use. See Remarks.
static readonly HttpClient client = new HttpClient();
static async Task Main()
{
// Call asynchronous network methods in a try/catch block to handle exceptions.
try
{
HttpResponseMessage response = await client.GetAsync("http://www.contoso.com/");
response.EnsureSuccessStatusCode();
string responseBody = await response.Content.ReadAsStringAsync();
// Above three lines can be replaced with new helper method below
// string responseBody = await client.GetStringAsync(uri);
Console.WriteLine(responseBody);
}
catch(HttpRequestException e)
{
Console.WriteLine("\nException Caught!");
Console.WriteLine("Message :{0} ",e.Message);
}
}
You can also check document Consume a RESTful web service, which demonstrates how to consume a RESTful web service from a Xamarin.Forms application.
Web service APIs that adhere to REST are called RESTful APIs, and are defined using:
- A base URI.
- HTTP methods, such as GET, POST, PUT, PATCH, or DELETE.
- A media type for the data, such as JavaScript Object Notation (JSON).
And there is also a sample about this, you can check it here: https://learn.microsoft.com/en-us/xamarin/xamarin-forms/data-cloud/web-services/rest .
Best Regards,
Jessie Zhang
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.