# Class ApiCall&lt;TRequest, TResponse&gt; (4.10.0)

<button class="button button-with-icon cloud-select-dropdown__button " aria-haspopup="true">Version latest</button>

- [4.10.0 (latest)](https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.ApiCall-2)
- [4.8.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/4.8.0/Google.Api.Gax.Grpc.ApiCall-2)
- [4.4.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/4.4.0/Google.Api.Gax.Grpc.ApiCall-2)
- [4.3.1](https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/4.3.1/Google.Api.Gax.Grpc.ApiCall-2)
- [4.2.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/4.2.0/Google.Api.Gax.Grpc.ApiCall-2)
- [4.0.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/4.0.0/Google.Api.Gax.Grpc.ApiCall-2)
- [3.2.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/3.2.0/Google.Api.Gax.Grpc.ApiCall-2)

    public sealed class ApiCall<TRequest, TResponse> where TRequest : class, IMessage<TRequest> where TResponse : class, IMessage<TResponse>

Bridge between an RPC method (with synchronous and asynchronous variants) and higher level
abstractions, applying call settings as required.

## Inheritance

[object](https://learn.microsoft.com/dotnet/api/system.object) \> ApiCall\<TRequest, TResponse\>

## Inherited Members

[object.Equals(object)](https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object)) [object.Equals(object, object)](https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object-system-object)) [object.GetHashCode()](https://learn.microsoft.com/dotnet/api/system.object.gethashcode) [object.GetType()](https://learn.microsoft.com/dotnet/api/system.object.gettype) [object.ReferenceEquals(object, object)](https://learn.microsoft.com/dotnet/api/system.object.referenceequals) [object.ToString()](https://learn.microsoft.com/dotnet/api/system.object.tostring)

## Namespace

[Google.Api.Gax.Grpc](https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc)

## Assembly

Google.Api.Gax.Grpc.dll

| ## Type Parameters ||
|---|---|
| **Name** | **Description** |
| `TRequest` | RPC request type |
| `TResponse` | RPC response type |

## Properties

### BaseCallSettings

    public CallSettings BaseCallSettings { get; }

The base [CallSettings](https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.CallSettings) for this API call; these can be further overridden by providing
a `CallSettings` to [Async(TRequest, CallSettings)](https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.ApiCall-2#Google_Api_Gax_Grpc_ApiCall_2_Async__0_Google_Api_Gax_Grpc_CallSettings_) or [Sync(TRequest, CallSettings)](https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.ApiCall-2#Google_Api_Gax_Grpc_ApiCall_2_Sync__0_Google_Api_Gax_Grpc_CallSettings_).

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.CallSettings` |   |

## Methods

### Async(TRequest, CallSettings)

    public Task<TResponse> Async(TRequest request, CallSettings perCallCallSettings)

Performs an RPC call asynchronously.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `TRequest` The RPC request. |
| `perCallCallSettings` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.CallSettings` The call settings to apply to this specific call, overriding defaults where necessary. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.threading.tasks.task-1` | A task representing the asynchronous operation. The result of the completed task will be the RPC response. |

### Sync(TRequest, CallSettings)

    public TResponse Sync(TRequest request, CallSettings perCallCallSettings)

Performs an RPC call synchronously.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `TRequest` The RPC request. |
| `perCallCallSettings` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.CallSettings` The call settings to apply to this specific call, overriding defaults where necessary. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `TResponse` | The RPC response. |

### WithCallSettingsOverlay(Func\<TRequest, CallSettings\>)

    public ApiCall<TRequest, TResponse> WithCallSettingsOverlay(Func<TRequest, CallSettings> callSettingsOverlayFn)

Constructs a new [ApiCall\<TRequest, TResponse\>](https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.ApiCall-2) that applies an overlay to
the underlying [CallSettings](https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.CallSettings). If a value exists in both the original and
the overlay, the overlay takes priority.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `callSettingsOverlayFn` | `https://learn.microsoft.com/dotnet/api/system.func-2https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.CallSettings` Function that builds the overlay [CallSettings](https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.CallSettings). |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.ApiCall-2` | A new [ApiCall\<TRequest, TResponse\>](https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.ApiCall-2) with the overlay applied. |

### WithExtractedGoogleRequestParam(RoutingHeaderExtractor\<TRequest\>)

    public ApiCall<TRequest, TResponse> WithExtractedGoogleRequestParam(RoutingHeaderExtractor<TRequest> extractor)

Constructs a new [ApiCall\<TRequest, TResponse\>](https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.ApiCall-2) that applies an x-goog-request-params header to each request,
using the [RoutingHeaderExtractor\<TRequest\>](https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.RoutingHeaderExtractor-1).

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `extractor` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.RoutingHeaderExtractor-1` The [RoutingHeaderExtractor\<TRequest\>](https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.RoutingHeaderExtractor-1) that extracts the value of the routing header from a request. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.ApiCall-2` | > A new [ApiCall\<TRequest, TResponse\>](https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.ApiCall-2) which applies the header on each request. |

**Remarks** Values produced by the function are URL-encoded.

### WithGoogleRequestParam(string, Func\<TRequest, string\>)

    public ApiCall<TRequest, TResponse> WithGoogleRequestParam(string parameterName, Func<TRequest, string> valueSelector)

Constructs a new [ApiCall\<TRequest, TResponse\>](https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.ApiCall-2) that applies an x-goog-request-params header to each request,
using the specified parameter name and a value derived from the request.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `parameterName` | `https://learn.microsoft.com/dotnet/api/system.string` The parameter name in the header. Must not be null. |
| `valueSelector` | `https://learn.microsoft.com/dotnet/api/system.func-2https://learn.microsoft.com/dotnet/api/system.string` A function to call on each request, to determine the value to specify in the header. The parameter must not be null, but may return null. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.ApiCall-2` | A new [ApiCall\<TRequest, TResponse\>](https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.ApiCall-2) which applies the header on each request. |

**Remarks** Values produced by the function are URL-encoded; it is expected that `parameterName` is already URL-encoded.