<< Click to Display Table of Contents >> RayVentory Data Hub > 12.6 u5 > Administration and User Guide > Advanced Topics > Data API Getting Table Data (All Rows) |
This is the simplest way of querying the data.
GET
http://[host]:[port]/v1/resultDatabase/table/<table-name>
Parameter |
Required |
Description |
---|---|---|
includeDataTypes |
No (default: true) |
This parameter is only relevant for CSV file requests.
If set to false, then the CSV will receive an extra token after the header name, which contains the desired value type, enclosed by square brackets.
If you omit this parameter or set it to true, the returned CSV will not have this extra information, and the CSV column names will be a 1-1 representation of the column names. |
Parameter |
Required |
Description |
---|---|---|
ApiKey |
Yes |
Your API key (see chapter Authentication and authorization for more information how to get it). |
The following code connects to the instance https://datahahub.local (using SSL and port 443) with authentication token M6KNS9Z-3404R00-Q42E4SG-1G4HKWT and then reads the content of the table Catalog_Software, which then gets written to local file c:\temp\results.csv. Note: The output may be different depending on available tables
$dataHubApiKey = "M6KNS9Z-3404R00-Q42E4SG-1G4HKWT"; $dataHubHostName = "https://datahub.local"; $dataHubPort = 443;
$tableName = "CatalogSoftware"; $outFile = "C:\temp\results.csv";
$urlAddress = "{0}:{1}/v1/resultDatabase/table/{2}" -f $dataHubHostName, $dataHubPort, $tableName
$headers = @{}; $headers["ApiKey"] = $dataHubApiKey;
$request = Invoke-WebRequest -Uri $urlAddress -Headers $headers -Method Get;
if ($request.StatusCode -eq 200) { Write-Host $request.Content; $request.Content | Out-File $outFile } else { throw "Could not list the tables. HTTP code {0}" -f $request.StatusCode; } |