Your first request over HTTP
In this tutorial, you use PowerShell to read data through the data service—first through the OData interface, then through the native API. It takes about ten minutes and no additional software.
Prerequisites
- a running data service and its address, here
https://daten.example.com - a key with a rule that can read at least one table: a personal key (
wkl_…) or a service key. If the sign-in policy requires a second factor for your key, use a read-only key that is exempt from the second factor for this tutorial. - PowerShell 7 or Windows PowerShell 5.1
Steps
1. Have the key ready for the session
Enter the key so that it doesn't end up in the command history:
$h = @{ 'X-Api-Key' = (Read-Host 'Key') } $base = 'https://daten.example.com'
2. Check that the service responds
Invoke-RestMethod "$base/health/ready"
The response is Healthy. This call doesn't require sign-in.
3. List the databases and tables
(Invoke-RestMethod "$base/odata/v4/" -Headers $h).value | Format-Table name, url (Invoke-RestMethod "$base/odata/v4/fachdaten/dbo/" -Headers $h).value | Select-Object -First 5 | Format-Table name, kind
The first list shows the aliases you can read; the second shows the tables and views of one schema
(kind = EntitySet). Replace fachdaten and dbo with names from your own lists.
4. Read, filter, and count rows
$r = Invoke-RestMethod "$base/odata/v4/fachdaten/dbo/Artikel?`$top=2&`$count=true&`$filter=Gruppe eq 'S'" -Headers $h $r.'@odata.count' $r.value | Format-Table
@odata.count tells you how many rows match the condition in total; value contains the first two.
The service translates $filter into SQL and lets the database do the filtering. The backtick before
$ keeps PowerShell from treating $top as a variable.
5. Read the same rows through the native API
$c = Invoke-RestMethod "$base/api/v1/cf/fachdaten/tables/Artikel.json?`$top=2&`$count=true" -Headers $h $c | Select-Object rowCount, window, totalCount, nextLink $c.data | Format-Table
The native API responds with data, rowCount, window, and—because of $count=true—totalCount.
Without $top, it returns a window of the default size and, if more rows follow, a nextLink.
Result
You've read the same data through both interfaces. With a key that has no read access to a table, the
service responds 404—exactly as it does for a table that doesn't exist.
Next steps
- HTTP: native API (reference)—writing, query options, response and error format
- HTTP: OData v4 (reference)—metadata document, grouping, next pages
- HTTP: sign-in (reference)—Windows account, SQL Server login, second factor