# HttpDataSource.QueryAsync Method

> HttpDataSource.QueryAsync method in the TX Sheet Control .NET API: Reads at most 16 MiB. Includes the syntax and a C# example.

- **Product:** TX Sheet Control
- **Section:** Documentation
- **Kind:** Method
- **Namespace:** `TXTextControl.TXSheetControl.Data`
- **Package:** `TXTextControl.TXSheetControl.Server` (assembly `TXTextControl.TXSheetControl.Data.Http.dll`, from the private NuGet feed or the supplied NuGet folder)
- **Path:** TX Sheet Control > API Reference > .NET API > TXTextControl.TXSheetControl.Data > HttpDataSource > HttpDataSource.QueryAsync Method
- **1375 words**
- **Web URL:** https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-data/httpdatasource/queryasync-method/
- **LLMs URL:** https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-data/httpdatasource/queryasync-method/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-data/httpdatasource/queryasync-method/llms-full.txt

---

Reads at most 16 MiB. Accepts {columns,rows}, an object array or an OData {value:\[...\]} envelope. Nested values are rejected. Remote next links are never followed implicitly.

### Syntax

```csharp
public Task<DataSnapshot> QueryAsync(DataRequest request, CancellationToken cancellationToken = default)
```

### Parameters

| Parameter | Type | Optional | Description |
|---|---|---|---|
| `request` | `DataRequest` | No | Value matching request's declared type and the owning object's validation rules. |
| `cancellationToken` | `CancellationToken` | Yes | Cancels waiting or execution as supported by this operation. |

### Return Value

`Task<DataSnapshot>`.

### Examples

Create a working report from bounded HTTP sales data. Supply an application-owned HttpClient and service URL; scope cached data to its actual audience.

```csharp
using System.Net.Http;
using TXTextControl.TXSheetControl.Data;
using TXTextControl.TXSheetControl.Server;

async Task<byte[]> BuildHttpDataSourceQueryAsync(ServerSheetControl control, HttpClient client, Uri serviceBase)
{
    var book = control.Workbook;
    var sheet = await book.Sheets.AtAsync(0);
    var source = new HttpDataSource(client, request => new HttpRequestMessage(HttpMethod.Get, new Uri(serviceBase, "sales?offset=" + request.Offset + "&limit=" + request.Limit)), ["Region", "Revenue"]);
    var registry = new DataSourceRegistry();
    registry.Register("sales-service", "regional-sales", source);

    var request = new DataRequest { Offset = 0, Limit = 100, Parameters = new Dictionary<string, object?> { ["year"] = 2026 } };
    var options = new DataQueryOptions { Timeout = TimeSpan.FromSeconds(15), CacheDuration = TimeSpan.FromMinutes(1), CacheScope = "public-regional-sales" };
    var snapshot = await source.QueryAsync(request);
    var values = new[] { snapshot.Columns.Cast<object?>().ToArray() }
        .Concat(snapshot.Rows.Select(row => row.ToArray())).ToArray();
    await sheet.Range($"A1:B{values.Length}").SetValuesAsync(values);
    await sheet.Range("A1:B1").FormatAsync(new { fontFamily = "Liberation Sans", fontSize = 16, bold = true, textColor = "#ffffff", fillColor = "#163b63" });
    return await control.SaveAsync(StreamType.PDF);
}
```

### Remarks

Use the member with an instance or settings object from the documented package. Await task-returning operations. Document-bound handles must be resolved again after loading or deleting their owner.

### See Also

- [HttpDataSource Class](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-data/httpdatasource/llms-full.txt)
- [Workbooks and Worksheets](https://docs.textcontrol.com/tx-sheet-control/spreadsheets/workbooks/llms-full.txt)
- [DataRequest Class](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-data/datarequest/llms-full.txt)
- [DataSnapshot Class](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-data/datasnapshot/llms-full.txt)

---

## Nearby

- **Previous:** [HttpDataSource.Capabilities Property](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-data/httpdatasource/capabilities-property/llms-full.txt)
- **Next:** [IDataSource Interface](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-data/idatasource/llms-full.txt)
