public string Get(string endpoint, Dictionary <string, string> queries)
        {
            SetHeaders();
            NameValueCollection queryStringCollection = new NameValueCollection(_queryStringCollection);

            if (queries != null)
            {
                foreach (KeyValuePair <string, string> query in queries)
                {
                    queryStringCollection.Add(query.Key, query.Value);
                }
            }

            _client.QueryString = queryStringCollection;

            try
            {
                string response = _client.DownloadString(serverURL + endpoint);
                return(response);
            }
            catch (WebException ex)
            {
                throw new Exception(ParseWebException(ex));
            }
        }
Beispiel #2
0
        public string Get(string endpoint, Dictionary <string, string> queries)
        {
            logger.Log(LogLevel.Debug, "setting headers");
            SetHeaders();

            logger.Log(LogLevel.Debug, "constructing query string");
            NameValueCollection queryStringCollection = new NameValueCollection(_queryStringCollection);

            if (queries != null)
            {
                foreach (KeyValuePair <string, string> query in queries)
                {
                    queryStringCollection.Add(query.Key, query.Value);
                }
            }

            _client.QueryString = queryStringCollection;

            try
            {
                logger.Log(LogLevel.Debug, "calling " + serverURL + endpoint);
                if (_client == null)
                {
                    logger.Log(LogLevel.Debug, "client is null for some reason..");
                }
                string response = _client.DownloadString(serverURL + endpoint);
                return(response);
            }
            catch (WebException ex)
            {
                logger.Log(LogLevel.Debug, "error: " + ex.Message);
                throw new Exception(ParseWebException(ex));
            }
        }