Example #1
0
        protected HttpRequestMessage GetRequestMessage(HttpMethod method, Uri uri)
        {
            if (uri == null)
            {
                throw new ArgumentNullException(nameof(uri));
            }

            HttpRequestMessage result = new HttpRequestMessage(method, uri);

            // Required for GitHub-API!
            UserAgentHelper.AddUserAgent(result);

            // Accept: application/vnd.github.v3+json
            result.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/vnd.github.v3+json"));

            if (this.IncludeApiPreviews)
            {
                // Needed to receive "topics" information (seems to be experimental).
                result.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/vnd.github.mercy-preview+json"));

                // Needed to receive "template" information (seems to be experimental).
                result.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/vnd.github.baptiste-preview+json"));
            }

            // TODO: Add more header information, if needed.

            return(result);
        }