public static string GetString(string uri, string method = HttpMethod.Get, WebMessageFormatType format = WebMessageFormatType.Json)
        {
            WebRequest request = WebRequest.Create(new Uri(uri));

            request.Timeout     = (1000 * 60 * 5);
            request.ContentType = format == WebMessageFormatType.Json ? "application/json" : "application/xml";
            request.Credentials = CredentialCache.DefaultCredentials;
            request.Method      = method;

            WebResponse response = null;

            try
            {
                response = request.GetResponse();
                StreamReader responseStream = new StreamReader(response.GetResponseStream());
                return(responseStream.ReadToEnd());
            }
            catch (WebException wex)
            {
                throw wex.ToException();
            }
            catch { throw; }
        }
 public NostromoApiClient(string baseUrl, WebMessageFormatType webMessageFormatType) : base(baseUrl, webMessageFormatType)
 {
 }
 public WebRequestClient(string baseUrl, WebMessageFormatType messageFormat = WebMessageFormatType.Json)
 {
     this.BaseUrl       = baseUrl;
     this.MessageFormat = messageFormat;
 }
Example #4
0
 protected ApiClientBase(string baseUrl, WebMessageFormatType messageFormat)
 {
     this.BaseUrl       = baseUrl;
     this.MessageFormat = messageFormat;
 }