private static void WriteResponse(RestResponse response) { if (response.CallSuccessful) { Console.WriteLine("Call was successful:"); Console.WriteLine(response.StatusCode); Console.WriteLine(response.Content); } else { Console.WriteLine("Error during call:"); Console.WriteLine(response.ErrorStatus); Console.WriteLine(response.CompleteErrorMessage); Console.WriteLine(response.Content); } }
/// <summary> /// todo all exceptions except WebException have to be handled by user /// </summary> public RestResponse SendRequest(RestRequest request) { string url = root + request.GetResourceAndQuery(); HttpWebRequest httpRequest = CreateHttpRequest(request, url); SetData(request, httpRequest); RestResponse response; try { HttpWebResponse httpResponse = (HttpWebResponse)httpRequest.GetResponse(); response = new RestResponse(httpResponse); this.Cookies.Add(httpResponse.Cookies); } catch (WebException ex) { response = new RestResponse(ex); } return response; }