Exemple #1
0
        public static GistSubmissionResponse CreateAnonymousGist(string description, bool isPublic, string contentFilename, string content)
        {
            var submission = new GistSubmission
            {
                Description = description,
                IsPublic    = isPublic,
                Files       = new Dictionary <string, GistFile>
                {
                    [contentFilename] = new GistFile {
                        Content = content
                    },
                },
            };

            var request = (HttpWebRequest)WebRequest.Create("https://api.github.com/gists");

            request.ContentType = "application/json";
            request.Method      = "POST";
            request.UserAgent   = "HLDJConverter";

            using (var writer = new StreamWriter(request.GetRequestStream()))
            {
                writer.Write(JsonConvert.SerializeObject(submission));
            }

            var response = (HttpWebResponse)request.GetResponse();

            using (var reader = new StreamReader(response.GetResponseStream()))
            {
                return(JsonConvert.DeserializeObject <GistSubmissionResponse>(reader.ReadToEnd()));
            }
        }
Exemple #2
0
        public static GistSubmissionResponse CreateAnonymousGist(string description, bool isPublic, string contentFilename, string content)
        {
            var submission = new GistSubmission
            {
                Description = description,
                IsPublic = isPublic,
                Files = new Dictionary<string, GistFile>
                {
                    [contentFilename] = new GistFile {Content = content},
                },
            };

            var request = (HttpWebRequest)WebRequest.Create("https://api.github.com/gists");
            request.ContentType = "application/json";
            request.Method = "POST";
            request.UserAgent = "HLDJConverter";

            using(var writer = new StreamWriter(request.GetRequestStream()))
            {
                writer.Write(JsonConvert.SerializeObject(submission));
            }

            var response = (HttpWebResponse)request.GetResponse();
            using(var reader = new StreamReader(response.GetResponseStream()))
            {
                return JsonConvert.DeserializeObject<GistSubmissionResponse>(reader.ReadToEnd());
            }
        }