Ejemplo n.º 1
0
        public async Task <HttpResponseMessage> PutJsonAsync <T>(string url, T postData, string accessToken = null)
        {
            var requestMessage = new HttpRequestMessage(HttpMethod.Put, url);

            if (!String.IsNullOrEmpty(accessToken))
            {
                requestMessage.Headers.Authorization = new AuthenticationHeaderValue(JwtBearerDefaults.AuthenticationScheme, accessToken);
            }
            requestMessage.Content = new StringContent(JsonConvert.SerializeObject(postData, SerializationConfig.GetDefaultJsonSerializerSettings()), Encoding.UTF8, "application/json");
            var responseMessage = await _client.SendAsync(requestMessage);

            return(responseMessage);
        }