Created
February 24, 2014 15:57
-
-
Save bithavoc/9191027 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public string WebGetString(Uri endpoint, string path, params WebParam[] queryParams) | |
| { | |
| System.Net.WebClient client = new System.Net.WebClient(); | |
| StringBuilder relativePath = new StringBuilder(path); | |
| var filteredParams = (from p in queryParams where p.Value != null select p).ToArray(); | |
| if (filteredParams != null && filteredParams.Length > 0) | |
| { | |
| relativePath.Append("?"); | |
| foreach (var param in filteredParams) | |
| { | |
| var escapedValue = System.Net.WebUtility.UrlEncode(param.Value); | |
| relativePath.AppendFormat("{0}={1}", param.Key, escapedValue); | |
| relativePath.Append("&"); | |
| } | |
| } | |
| var uri = new Uri(endpoint, relativePath.ToString()); | |
| var responseString = client.DownloadString(uri); | |
| return responseString; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment