Exemplo n.º 1
0
        public static async Task <HttpResponseMessage> CallRestAPI(string token, string url,
                                                                   string httpMethod, string jsonContent, ILogger log, string contentType = "application/json")
        {
            var httpClient = HttpClientPool.GetInstance(new Uri(url), token);
            var method     = new HttpMethod(httpMethod);
            var request    = new HttpRequestMessage(method, url);

            if (!string.IsNullOrEmpty(jsonContent))
            {
                request.Content = new StringContent(jsonContent, Encoding.UTF8, contentType);
            }
            return(await httpClient.SendAsync(request));
        }
Exemplo n.º 2
0
        public static async Task <HttpResponseMessage> CallVSTSAPI(string accountName, string pat, string url,
                                                                   string httpMethod, string jsonContent, string contentType = "application/json")
        {
            string Url        = string.Format(url, accountName);
            var    httpClient = HttpClientPool.GetInstance(new Uri(url), pat);
            var    method     = new HttpMethod(httpMethod);
            var    request    = new HttpRequestMessage(method, Url);

            if (!string.IsNullOrEmpty(jsonContent))
            {
                request.Content = new StringContent(jsonContent, Encoding.UTF8, contentType);
            }
            return(await httpClient.SendAsync(request));
        }