public BatchRequest(IClientService service, string batchUrl)
Constructs a new batch request using the given service. The service's HTTP client is used to create a
request to the given server URL and its serializer members are used to serialize the request and
deserialize the response.
[[["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\u003eThe \u003ccode\u003eBatchRequest\u003c/code\u003e class facilitates sending multiple requests to Google servers as a single batch operation.\u003c/p\u003e\n"],["\u003cp\u003eIndividual service requests are added to a \u003ccode\u003eBatchRequest\u003c/code\u003e instance using the \u003ccode\u003eQueue<TResponse>(IClientServiceRequest, OnResponse<TResponse>)\u003c/code\u003e method.\u003c/p\u003e\n"],["\u003cp\u003eAll queued requests within a \u003ccode\u003eBatchRequest\u003c/code\u003e can be executed simultaneously using the \u003ccode\u003eExecuteAsync()\u003c/code\u003e method.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eBatchRequest\u003c/code\u003e class can be constructed with an \u003ccode\u003eIClientService\u003c/code\u003e, and optionally a batch URL, to handle request serialization and response deserialization.\u003c/p\u003e\n"],["\u003cp\u003eThe number of requests currently queued in a \u003ccode\u003eBatchRequest\u003c/code\u003e can be retrieved using the \u003ccode\u003eCount\u003c/code\u003e property.\u003c/p\u003e\n"]]],[],null,["# Class BatchRequest (1.69.0)\n\nVersion latestkeyboard_arrow_down\n\n- [1.69.0 (latest)](/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Requests.BatchRequest)\n- [1.68.0](/dotnet/docs/reference/Google.Apis/1.68.0/Google.Apis.Requests.BatchRequest)\n- [1.60.0](/dotnet/docs/reference/Google.Apis/1.60.0/Google.Apis.Requests.BatchRequest)\n- [1.59.0](/dotnet/docs/reference/Google.Apis/1.59.0/Google.Apis.Requests.BatchRequest)\n- [1.55.0](/dotnet/docs/reference/Google.Apis/1.55.0/Google.Apis.Requests.BatchRequest)\n- [1.50.0](/dotnet/docs/reference/Google.Apis/1.50.0/Google.Apis.Requests.BatchRequest) \n\n public sealed class BatchRequest\n\nA batch request which represents individual requests to Google servers. You should add a single service\nrequest using the [Queue\\\u003cTResponse\\\u003e(IClientServiceRequest, OnResponse\\\u003cTResponse\\\u003e)](/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Requests.BatchRequest#Google_Apis_Requests_BatchRequest_Queue__1_Google_Apis_Requests_IClientServiceRequest_Google_Apis_Requests_BatchRequest_OnResponse___0__) method and execute all individual requests using\n[ExecuteAsync()](/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Requests.BatchRequest#Google_Apis_Requests_BatchRequest_ExecuteAsync). More information about the batch protocol is available in\n\u003chttps://developers.google.com/storage/docs/json_api/v1/how-tos/batch\u003e. \n\nInheritance\n-----------\n\n[object](https://learn.microsoft.com/dotnet/api/system.object) \\\u003e BatchRequest \n\nInherited Members\n-----------------\n\n[object.Equals(object)](https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object)) \n[object.Equals(object, object)](https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object-system-object)) \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.ReferenceEquals(object, object)](https://learn.microsoft.com/dotnet/api/system.object.referenceequals) \n[object.ToString()](https://learn.microsoft.com/dotnet/api/system.object.tostring)\n\nNamespace\n---------\n\n[Google.Apis.Requests](/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Requests)\n\nAssembly\n--------\n\nGoogle.Apis.dll\n\nConstructors\n------------\n\n### BatchRequest(IClientService)\n\n public BatchRequest(IClientService service)\n\nConstructs a new batch request using the given service. See\n[BatchRequest(IClientService, string)](/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Requests.BatchRequest#Google_Apis_Requests_BatchRequest__ctor_Google_Apis_Services_IClientService_System_String_) for more information.\n\n### BatchRequest(IClientService, string)\n\n public BatchRequest(IClientService service, string batchUrl)\n\nConstructs a new batch request using the given service. The service's HTTP client is used to create a\nrequest to the given server URL and its serializer members are used to serialize the request and\ndeserialize the response.\n\nProperties\n----------\n\n### Count\n\n public int Count { get; }\n\nGets the count of all queued requests.\n\nMethods\n-------\n\n### ExecuteAsync()\n\n public Task ExecuteAsync()\n\nAsynchronously executes the batch request.\n\n### ExecuteAsync(CancellationToken)\n\n public Task ExecuteAsync(CancellationToken cancellationToken)\n\nAsynchronously executes the batch request.\n\n### Queue\\\u003cTResponse\\\u003e(IClientServiceRequest, OnResponse\\\u003cTResponse\\\u003e)\n\n public void Queue\u003cTResponse\u003e(IClientServiceRequest request, BatchRequest.OnResponse\u003cTResponse\u003e callback) where TResponse : class\n\nQueues an individual request.\n\nExtension Method\n----------------\n\n[Utilities.ThrowIfNull\\\u003cT\\\u003e(T, string)](/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Util.Utilities#Google_Apis_Util_Utilities_ThrowIfNull__1___0_System_String_)"]]