RestClient client = new RestClient("https://api.example.com/"); RestRequest request = new RestRequest("endpoint", Method.GET); RestResponse response = client.Execute(request); if (response.StatusCode == HttpStatusCode.OK) { // Parse response and do something with data } else { // Handle error response }
RestClient client = new RestClient("https://api.example.com/"); RestRequest request = new RestRequest("endpoint", Method.POST); request.AddParameter("key1", "value1"); request.AddParameter("key2", "value2"); RestResponse response = client.ExecuteIn both examples, the RestResponse class is used to handle the response received from the Restful web service. The response object contains information such as the status code, content, and headers. It is then used to determine whether the request was successful or not, and to handle the response accordingly.(request); if (response.StatusCode == HttpStatusCode.Created) { // Handle successful response } else { // Handle error response }