RestSharp
The idea behind RestSharp is very similar to the base HttpClient
—reducing code duplicity. It simplifies the creation of a request and provides a lot of the utility for making HTTP calls. Redo StarWarsClient
using RestSharp
, but first, you'll install the RestSharp
NuGet:
dotnet add package RestSharp
Now create a client that is very similar to the one you created in Activity 8.01:
public class StarWarsClient { private readonly RestClient _client; public StarWarsClient() { _client = new RestClient("https://swapi.dev/api/"); }
Having RestSharp
created gives you a response serialization out of the box. It is also able to guess which HTTP...