public sealed class HttpRequest : IMessage<HttpRequest>, IEquatable<HttpRequest>, IDeepCloneable<HttpRequest>, IBufferMessage, IMessage
Reference documentation and code samples for the Google Cloud Tasks v2beta3 API class HttpRequest.
HTTP request.
The task will be pushed to the worker as an HTTP request. If the worker
or the redirected worker acknowledges the task by returning a successful HTTP
response code ([200 - 299]), the task will be removed from the queue. If
any other HTTP response code is returned or no response is received, the
task will be retried according to the following:
User-specified throttling: [retry
configuration][google.cloud.tasks.v2beta3.Queue.retry_config],
[rate limits][google.cloud.tasks.v2beta3.Queue.rate_limits], and the
[queue's state][google.cloud.tasks.v2beta3.Queue.state].
System throttling: To prevent the worker from overloading, Cloud Tasks may
temporarily reduce the queue's effective rate. User-specified settings
will not be changed.
System throttling happens because:
Cloud Tasks backs off on all errors. Normally the backoff specified in
[rate limits][google.cloud.tasks.v2beta3.Queue.rate_limits] will be used.
But if the worker returns 429 (Too Many Requests), 503 (Service
Unavailable), or the rate of errors is high, Cloud Tasks will use a
higher backoff rate. The retry specified in the Retry-After HTTP
response header is considered.
To prevent traffic spikes and to smooth sudden increases in traffic,
dispatches ramp up slowly when the queue is newly created or idle and
if large numbers of tasks suddenly become available to dispatch (due to
spikes in create task rates, the queue being unpaused, or many tasks
that are scheduled at the same time).
A request body is allowed only if the
[HTTP method][google.cloud.tasks.v2beta3.HttpRequest.http_method] is POST,
PUT, or PATCH. It is an error to set body on a task with an incompatible
[HttpMethod][google.cloud.tasks.v2beta3.HttpMethod].
This map contains the header field names and values.
Headers can be set when the
[task is created][google.cloud.tasks.v2beta3.CloudTasks.CreateTask].
These headers represent a subset of the headers that will accompany the
task's HTTP request. Some HTTP request headers will be ignored or replaced.
A partial list of headers that will be ignored or replaced is:
Any header that is prefixed with "X-CloudTasks-" will be treated
as service header. Service headers define properties of the task and are
predefined in CloudTask.
Host: This will be computed by Cloud Tasks and derived from
[HttpRequest.url][google.cloud.tasks.v2beta3.HttpRequest.url].
Content-Length: This will be computed by Cloud Tasks.
User-Agent: This will be set to "Google-Cloud-Tasks".
X-Google-*: Google use only.
X-AppEngine-*: Google use only.
Content-Type won't be set by Cloud Tasks. You can explicitly set
Content-Type to a media type when the
[task is created][google.cloud.tasks.v2beta3.CloudTasks.CreateTask].
For example, Content-Type can be set to "application/octet-stream" or
"application/json".
Headers which can have multiple values (according to RFC2616) can be
specified using comma-separated values.
Required. The full url path that the request will be sent to.
This string must begin with either "http://" or "https://". Some examples
are: http://acme.com and https://acme.com/sales:8080. Cloud Tasks will
encode some characters for safety and compatibility. The maximum allowed
URL length is 2083 characters after encoding.
The Location header response from a redirect response [300 - 399]
may be followed. The redirect is not counted as a separate attempt.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-04 UTC."],[[["\u003cp\u003eThis document provides reference information for the \u003ccode\u003eHttpRequest\u003c/code\u003e class within the Google Cloud Tasks v2beta3 API, detailing how tasks are pushed as HTTP requests to worker services.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eHttpRequest\u003c/code\u003e class allows for specifying details such as the HTTP method, URL, headers, and body, along with authentication options like OAuth or OIDC tokens.\u003c/p\u003e\n"],["\u003cp\u003eCloud Tasks manages the retries of failed HTTP requests based on user-specified configurations, queue state, and system throttling to prevent worker overload, including considerations for error codes and backoff strategies.\u003c/p\u003e\n"],["\u003cp\u003eWhen setting headers, some are replaced or ignored by Cloud Tasks, such as those with the prefix "X-CloudTasks-", as well as \u003ccode\u003eHost\u003c/code\u003e, \u003ccode\u003eContent-Length\u003c/code\u003e, \u003ccode\u003eUser-Agent\u003c/code\u003e, \u003ccode\u003eX-Google-*\u003c/code\u003e, and \u003ccode\u003eX-AppEngine-*\u003c/code\u003e headers.\u003c/p\u003e\n"],["\u003cp\u003eThe URL used in an \u003ccode\u003eHttpRequest\u003c/code\u003e must start with "http://" or "https://" and is subject to a maximum length of 2083 characters, with Cloud Tasks potentially following redirect responses indicated by \u003ccode\u003eLocation\u003c/code\u003e headers.\u003c/p\u003e\n"]]],[],null,["# Google Cloud Tasks v2beta3 API - Class HttpRequest (3.0.0-beta07)\n\nVersion latestkeyboard_arrow_down\n\n- [3.0.0-beta07 (latest)](/dotnet/docs/reference/Google.Cloud.Tasks.V2Beta3/latest/Google.Cloud.Tasks.V2Beta3.HttpRequest)\n- [3.0.0-beta06](/dotnet/docs/reference/Google.Cloud.Tasks.V2Beta3/3.0.0-beta06/Google.Cloud.Tasks.V2Beta3.HttpRequest)\n- [2.0.0-beta08](/dotnet/docs/reference/Google.Cloud.Tasks.V2Beta3/2.0.0-beta08/Google.Cloud.Tasks.V2Beta3.HttpRequest) \n\n public sealed class HttpRequest : IMessage\u003cHttpRequest\u003e, IEquatable\u003cHttpRequest\u003e, IDeepCloneable\u003cHttpRequest\u003e, IBufferMessage, IMessage\n\nReference documentation and code samples for the Google Cloud Tasks v2beta3 API class HttpRequest.\n\nHTTP request.\n\nThe task will be pushed to the worker as an HTTP request. If the worker\nor the redirected worker acknowledges the task by returning a successful HTTP\nresponse code (\\[`200` - `299`\\]), the task will be removed from the queue. If\nany other HTTP response code is returned or no response is received, the\ntask will be retried according to the following:\n\n- User-specified throttling: \\[retry\n configuration\\]\\[google.cloud.tasks.v2beta3.Queue.retry_config\\],\n \\[rate limits\\]\\[google.cloud.tasks.v2beta3.Queue.rate_limits\\], and the\n \\[queue's state\\]\\[google.cloud.tasks.v2beta3.Queue.state\\].\n\n- System throttling: To prevent the worker from overloading, Cloud Tasks may\n temporarily reduce the queue's effective rate. User-specified settings\n will not be changed.\n\n System throttling happens because:\n - Cloud Tasks backs off on all errors. Normally the backoff specified in\n \\[rate limits\\]\\[google.cloud.tasks.v2beta3.Queue.rate_limits\\] will be used.\n But if the worker returns `429` (Too Many Requests), `503` (Service\n Unavailable), or the rate of errors is high, Cloud Tasks will use a\n higher backoff rate. The retry specified in the `Retry-After` HTTP\n response header is considered.\n\n - To prevent traffic spikes and to smooth sudden increases in traffic,\n dispatches ramp up slowly when the queue is newly created or idle and\n if large numbers of tasks suddenly become available to dispatch (due to\n spikes in create task rates, the queue being unpaused, or many tasks\n that are scheduled at the same time).\n\nInheritance\n-----------\n\n[object](https://learn.microsoft.com/dotnet/api/system.object) \\\u003e HttpRequest \n\nImplements\n----------\n\n[IMessage](https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IMessage-1.html)[HttpRequest](/dotnet/docs/reference/Google.Cloud.Tasks.V2Beta3/latest/Google.Cloud.Tasks.V2Beta3.HttpRequest), [IEquatable](https://learn.microsoft.com/dotnet/api/system.iequatable-1)[HttpRequest](/dotnet/docs/reference/Google.Cloud.Tasks.V2Beta3/latest/Google.Cloud.Tasks.V2Beta3.HttpRequest), [IDeepCloneable](https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IDeepCloneable-1.html)[HttpRequest](/dotnet/docs/reference/Google.Cloud.Tasks.V2Beta3/latest/Google.Cloud.Tasks.V2Beta3.HttpRequest), [IBufferMessage](https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IBufferMessage.html), [IMessage](https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IMessage.html) \n\nInherited Members\n-----------------\n\n[object.GetHashCode()](https://learn.microsoft.com/dotnet/api/system.object.gethashcode) \n[object.GetType()](https://learn.microsoft.com/dotnet/api/system.object.gettype) \n[object.ToString()](https://learn.microsoft.com/dotnet/api/system.object.tostring)\n\nNamespace\n---------\n\n[Google.Cloud.Tasks.V2Beta3](/dotnet/docs/reference/Google.Cloud.Tasks.V2Beta3/latest/Google.Cloud.Tasks.V2Beta3)\n\nAssembly\n--------\n\nGoogle.Cloud.Tasks.V2Beta3.dll\n\nConstructors\n------------\n\n### HttpRequest()\n\n public HttpRequest()\n\n### HttpRequest(HttpRequest)\n\n public HttpRequest(HttpRequest other)\n\nProperties\n----------\n\n### AuthorizationHeaderCase\n\n public HttpRequest.AuthorizationHeaderOneofCase AuthorizationHeaderCase { get; }\n\n### Body\n\n public ByteString Body { get; set; }\n\nHTTP request body.\n\nA request body is allowed only if the\n\\[HTTP method\\]\\[google.cloud.tasks.v2beta3.HttpRequest.http_method\\] is POST,\nPUT, or PATCH. It is an error to set body on a task with an incompatible\n\\[HttpMethod\\]\\[google.cloud.tasks.v2beta3.HttpMethod\\].\n\n### Headers\n\n public MapField\u003cstring, string\u003e Headers { get; }\n\nHTTP request headers.\n\nThis map contains the header field names and values.\nHeaders can be set when the\n\\[task is created\\]\\[google.cloud.tasks.v2beta3.CloudTasks.CreateTask\\].\n\nThese headers represent a subset of the headers that will accompany the\ntask's HTTP request. Some HTTP request headers will be ignored or replaced.\n\nA partial list of headers that will be ignored or replaced is:\n\n- Any header that is prefixed with \"X-CloudTasks-\" will be treated as service header. Service headers define properties of the task and are predefined in CloudTask.\n- Host: This will be computed by Cloud Tasks and derived from \\[HttpRequest.url\\]\\[google.cloud.tasks.v2beta3.HttpRequest.url\\].\n- Content-Length: This will be computed by Cloud Tasks.\n- User-Agent: This will be set to `\"Google-Cloud-Tasks\"`.\n- `X-Google-*`: Google use only.\n- `X-AppEngine-*`: Google use only.\n\n`Content-Type` won't be set by Cloud Tasks. You can explicitly set\n`Content-Type` to a media type when the\n\\[task is created\\]\\[google.cloud.tasks.v2beta3.CloudTasks.CreateTask\\].\nFor example, `Content-Type` can be set to `\"application/octet-stream\"` or\n`\"application/json\"`.\n\nHeaders which can have multiple values (according to RFC2616) can be\nspecified using comma-separated values.\n\nThe size of the headers must be less than 80KB.\n\n### HttpMethod\n\n public HttpMethod HttpMethod { get; set; }\n\nThe HTTP method to use for the request. The default is POST.\n\n### OauthToken\n\n public OAuthToken OauthToken { get; set; }\n\nIf specified, an\n[OAuth token](https://developers.google.com/identity/protocols/OAuth2)\nwill be generated and attached as an `Authorization` header in the HTTP\nrequest.\n\nThis type of authorization should generally only be used when calling\nGoogle APIs hosted on \\*.googleapis.com.\n\n### OidcToken\n\n public OidcToken OidcToken { get; set; }\n\nIf specified, an\n[OIDC](https://developers.google.com/identity/protocols/OpenIDConnect)\ntoken will be generated and attached as an `Authorization` header in the\nHTTP request.\n\nThis type of authorization can be used for many scenarios, including\ncalling Cloud Run, or endpoints where you intend to validate the token\nyourself.\n\n### Url\n\n public string Url { get; set; }\n\nRequired. The full url path that the request will be sent to.\n\nThis string must begin with either \"http://\" or \"https://\". Some examples\nare: `http://acme.com` and `https://acme.com/sales:8080`. Cloud Tasks will\nencode some characters for safety and compatibility. The maximum allowed\nURL length is 2083 characters after encoding.\n\nThe `Location` header response from a redirect response \\[`300` - `399`\\]\nmay be followed. The redirect is not counted as a separate attempt."]]