Edit

Share via


HttpClient.Send Method

Definition

Overloads

Send(HttpRequestMessage)

Sends an HTTP request with the specified request.

Send(HttpRequestMessage, HttpCompletionOption)

Sends an HTTP request.

Send(HttpRequestMessage, CancellationToken)

Sends an HTTP request with the specified request and cancellation token.

Send(HttpRequestMessage, HttpCompletionOption, CancellationToken)

Sends an HTTP request with the specified request, completion option and cancellation token.

Send(HttpRequestMessage)

Source:
HttpClient.cs
Source:
HttpClient.cs
Source:
HttpClient.cs

Sends an HTTP request with the specified request.

public:
 System::Net::Http::HttpResponseMessage ^ Send(System::Net::Http::HttpRequestMessage ^ request);
public System.Net.Http.HttpResponseMessage Send (System.Net.Http.HttpRequestMessage request);
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public System.Net.Http.HttpResponseMessage Send (System.Net.Http.HttpRequestMessage request);
override this.Send : System.Net.Http.HttpRequestMessage -> System.Net.Http.HttpResponseMessage
[<System.Runtime.Versioning.UnsupportedOSPlatform("browser")>]
override this.Send : System.Net.Http.HttpRequestMessage -> System.Net.Http.HttpResponseMessage
Public Function Send (request As HttpRequestMessage) As HttpResponseMessage

Parameters

request
HttpRequestMessage

The HTTP request message to send.

Returns

An HTTP response message.

Attributes

Exceptions

The request is null.

The HTTP version is 2.0 or higher or the version policy is set to RequestVersionOrHigher.

-or-

The custom class derived from HttpContent does not override the SerializeToStream(Stream, TransportContext, CancellationToken) method.

-or-

The custom HttpMessageHandler does not override the Send(HttpRequestMessage, CancellationToken) method.

The request message was already sent by the HttpClient instance.

The request failed due to an underlying issue such as network connectivity, DNS failure, or server certificate validation.

If the TaskCanceledException exception nests the TimeoutException: The request failed due to timeout.

Applies to

Send(HttpRequestMessage, HttpCompletionOption)

Source:
HttpClient.cs
Source:
HttpClient.cs
Source:
HttpClient.cs

Sends an HTTP request.

public:
 System::Net::Http::HttpResponseMessage ^ Send(System::Net::Http::HttpRequestMessage ^ request, System::Net::Http::HttpCompletionOption completionOption);
public System.Net.Http.HttpResponseMessage Send (System.Net.Http.HttpRequestMessage request, System.Net.Http.HttpCompletionOption completionOption);
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public System.Net.Http.HttpResponseMessage Send (System.Net.Http.HttpRequestMessage request, System.Net.Http.HttpCompletionOption completionOption);
override this.Send : System.Net.Http.HttpRequestMessage * System.Net.Http.HttpCompletionOption -> System.Net.Http.HttpResponseMessage
[<System.Runtime.Versioning.UnsupportedOSPlatform("browser")>]
override this.Send : System.Net.Http.HttpRequestMessage * System.Net.Http.HttpCompletionOption -> System.Net.Http.HttpResponseMessage
Public Function Send (request As HttpRequestMessage, completionOption As HttpCompletionOption) As HttpResponseMessage

Parameters

request
HttpRequestMessage

The HTTP request message to send.

completionOption
HttpCompletionOption

One of the enumeration values that specifies when the operation should complete (as soon as a response is available or after reading the response content).

Returns

The HTTP response message.

Attributes

Exceptions

The request is null.

The HTTP version is 2.0 or higher or the version policy is set to RequestVersionOrHigher.

-or-

The custom class derived from HttpContent does not override the SerializeToStream(Stream, TransportContext, CancellationToken) method.

-or-

The custom HttpMessageHandler does not override the Send(HttpRequestMessage, CancellationToken) method.

The request message was already sent by the HttpClient instance.

The request failed due to an underlying issue such as network connectivity, DNS failure, or server certificate validation.

If the TaskCanceledException exception nests the TimeoutException: The request failed due to timeout.

Applies to

Send(HttpRequestMessage, CancellationToken)

Source:
HttpClient.cs
Source:
HttpClient.cs
Source:
HttpClient.cs

Sends an HTTP request with the specified request and cancellation token.

public:
 override System::Net::Http::HttpResponseMessage ^ Send(System::Net::Http::HttpRequestMessage ^ request, System::Threading::CancellationToken cancellationToken);
public override System.Net.Http.HttpResponseMessage Send (System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken);
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public override System.Net.Http.HttpResponseMessage Send (System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken);
override this.Send : System.Net.Http.HttpRequestMessage * System.Threading.CancellationToken -> System.Net.Http.HttpResponseMessage
[<System.Runtime.Versioning.UnsupportedOSPlatform("browser")>]
override this.Send : System.Net.Http.HttpRequestMessage * System.Threading.CancellationToken -> System.Net.Http.HttpResponseMessage
Public Overrides Function Send (request As HttpRequestMessage, cancellationToken As CancellationToken) As HttpResponseMessage

Parameters

request
HttpRequestMessage

The HTTP request message to send.

cancellationToken
CancellationToken

The token to cancel the operation.

Returns

The HTTP response message.

Attributes

Exceptions

The request is null.

The HTTP version is 2.0 or higher or the version policy is set to RequestVersionOrHigher.

-or-

The custom class derived from HttpContent does not override the SerializeToStream(Stream, TransportContext, CancellationToken) method.

-or-

The custom HttpMessageHandler does not override the Send(HttpRequestMessage, CancellationToken) method.

The request message was already sent by the HttpClient instance.

The request failed due to an underlying issue such as network connectivity, DNS failure, or server certificate validation.

The request was canceled.

-or-

If the TaskCanceledException exception nests the TimeoutException: The request failed due to timeout.

The cancellation token was canceled. This exception is stored into the returned task.

Applies to

Send(HttpRequestMessage, HttpCompletionOption, CancellationToken)

Source:
HttpClient.cs
Source:
HttpClient.cs
Source:
HttpClient.cs

Sends an HTTP request with the specified request, completion option and cancellation token.

public:
 System::Net::Http::HttpResponseMessage ^ Send(System::Net::Http::HttpRequestMessage ^ request, System::Net::Http::HttpCompletionOption completionOption, System::Threading::CancellationToken cancellationToken);
public System.Net.Http.HttpResponseMessage Send (System.Net.Http.HttpRequestMessage request, System.Net.Http.HttpCompletionOption completionOption, System.Threading.CancellationToken cancellationToken);
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public System.Net.Http.HttpResponseMessage Send (System.Net.Http.HttpRequestMessage request, System.Net.Http.HttpCompletionOption completionOption, System.Threading.CancellationToken cancellationToken);
override this.Send : System.Net.Http.HttpRequestMessage * System.Net.Http.HttpCompletionOption * System.Threading.CancellationToken -> System.Net.Http.HttpResponseMessage
[<System.Runtime.Versioning.UnsupportedOSPlatform("browser")>]
override this.Send : System.Net.Http.HttpRequestMessage * System.Net.Http.HttpCompletionOption * System.Threading.CancellationToken -> System.Net.Http.HttpResponseMessage
Public Function Send (request As HttpRequestMessage, completionOption As HttpCompletionOption, cancellationToken As CancellationToken) As HttpResponseMessage

Parameters

request
HttpRequestMessage

The HTTP request message to send.

completionOption
HttpCompletionOption

One of the enumeration values that specifies when the operation should complete (as soon as a response is available or after reading the response content).

cancellationToken
CancellationToken

The token to cancel the operation.

Returns

The HTTP response message.

Attributes

Exceptions

The request is null.

The HTTP version is 2.0 or higher or the version policy is set to RequestVersionOrHigher.

-or-

The custom class derived from HttpContent does not override the SerializeToStream(Stream, TransportContext, CancellationToken) method.

-or-

The custom HttpMessageHandler does not override the Send(HttpRequestMessage, CancellationToken) method.

The request message was already sent by the HttpClient instance.

The request failed due to an underlying issue such as network connectivity, DNS failure, or server certificate validation.

The request was canceled.

-or-

If the TaskCanceledException exception nests the TimeoutException: The request failed due to timeout.

The cancellation token was canceled. This exception is stored into the returned task.

Applies to