Skip to main content

Connect Power BI to the Data API

Power BI Desktop can call the Data API through Power Query. Start with a small result, verify the schema, and then expand the query.

Prerequisites

  • Power BI Desktop on Windows
  • A Corva API key with read access
  • The target dataset and an accessible asset_id or company_id

Create a blank query

  1. In Power BI Desktop, select Get data and then Blank query.
  2. Open Advanced Editor.
  3. Replace the editor contents with the query below.
  4. Replace 12345 and YOUR_API_KEY.
let
Url = "https://data.corva.ai/api/v1/data/corva/metrics/",
Parameters = [
query = "{""asset_id"":12345}",
limit = "100",
sort = "{""timestamp"":-1}",
fields = "timestamp,asset_id,data.key,data.value"
],
Source = Json.Document(
Web.Contents(
Url,
[
Headers = [Authorization = "API YOUR_API_KEY"],
Query = Parameters
]
)
),
Results = Table.FromRecords(Source)
in
Results

Shape the result

  1. Convert the returned list to a table if Power BI has not already done so.
  2. Expand the data record.
  3. Assign appropriate data types to timestamp and metric values.
  4. Rename the query to identify the dataset and filter.
  5. Refresh the preview before building visuals.

Keep the key out of the query

The inline placeholder is useful only for the first local test. For a maintained report, store the credential in an approved Power BI data-source or gateway configuration. Do not publish a report containing a real key in the query text.

Troubleshooting

SymptomCheck
401 UnauthorizedThe header must use API followed by the current key.
403 ForbiddenThe key may not have access to the asset or dataset.
Empty tableVerify the asset ID, dataset, and filter.
Refresh is slowReduce the time range, limit, and returned fields.
Formula firewall errorReview Power BI privacy levels and gateway configuration.

Use Filtering, Sorting, and Pagination to build additional query parameters.