System.Net.Http.HttpClient.SendAsync C# (CSharp) Method

SendAsync() public method

public SendAsync ( HttpRequestMessage request, HttpCompletionOption completionOption ) : Task
request HttpRequestMessage
completionOption HttpCompletionOption
return Task
        public Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, HttpCompletionOption completionOption)
        {
            return SendAsync(request, completionOption, CancellationToken.None);
        }

Same methods

HttpClient::SendAsync ( HttpRequestMessage request ) : Task
HttpClient::SendAsync ( HttpRequestMessage request, CancellationToken cancellationToken ) : Task
HttpClient::SendAsync ( HttpRequestMessage request, HttpCompletionOption completionOption, CancellationToken cancellationToken ) : Task

Usage Example

Exemplo n.º 1
6
        public static async Task<bool> ChangeUserProfile(String name, String url, String description, String location,
            UserAccountEntity userAccountEntity)
        {
            if (userAccountEntity.GetAccessToken().Equals("refresh"))
            {
                await Auth.RefreshAccessToken(userAccountEntity);
            }
            var param = new Dictionary<String, String>();
            if (!string.IsNullOrEmpty(name)) param.Add("name", name);
            if (!string.IsNullOrEmpty(url)) param.Add("url", url);
            if (!string.IsNullOrEmpty(location)) param.Add("location", location);
            if (!string.IsNullOrEmpty(description)) param.Add("description", description);

            var theAuthClient = new HttpClient();
            HttpContent header = new FormUrlEncodedContent(param);
            var request = new HttpRequestMessage(HttpMethod.Post, EndPoints.ACCOUNT_UPDATE) {Content = header};
            request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", userAccountEntity.GetAccessToken());
            try
            {
                HttpResponseMessage response = await theAuthClient.SendAsync(request);
                return response.IsSuccessStatusCode;
            }
            catch (Exception)
            {
                return false;
            }
        }
All Usage Examples Of System.Net.Http.HttpClient::SendAsync