var client = new RestClient("https://api.example.com"); var request = new RestRequest("users/1", Method.GET); IRestResponse response = client.Execute(request); var content = response.Content; // JSON response
var client = new RestClient("https://api.example.com"); var request = new RestRequest("users", Method.POST); request.AddParameter("name", "John Doe"); request.AddParameter("email", "[email protected]"); IRestResponse response = client.Execute(request); var content = response.Content; // JSON responseThis code sends a POST request to the API endpoint "/users" with two parameters in the request body - name and email. Again, RestSharp's Execute() method is used to send the request and retrieve the response in JSON format. Package library: RestSharp (available on NuGet)