Skip to content

Instantly share code, notes, and snippets.

@scottksmith95
Created June 25, 2012 15:44
Show Gist options
  • Save scottksmith95/2989347 to your computer and use it in GitHub Desktop.
Save scottksmith95/2989347 to your computer and use it in GitHub Desktop.
JSON from API as a string
using System;
using System.Net;
public class ApiRequest
{
readonly static WebClient WebClient = new WebClient();
public static string GetJson(Uri uri)
{
return WebClient.DownloadString(uri);
}
}
using System;
class Program
{
const string GitHubPath = "https://api.github.com/users/scottksmith95";
static void Main(string[] args)
{
var gitHubUri = new Uri(GitHubPath);
var json = ApiRequest.GetJson(gitHubUri);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment