Power BI metadata and refresh
Inventory the model before operating on it
The Power BI REST API uses legacy groups and datasets path names for workspaces and semantic models. Display names are not reliable identifiers. Read metadata using workspace and item IDs, then record the report-to-model association. A report may reference a model outside the current workspace; distinguish an unresolved link from a missing model. Do not enumerate the whole tenant when one authorized workspace suffices.
Read endpoints and operation boundaries
Use GET /groups, /groups/{groupId}/reports, and /groups/{groupId}/datasets beneath the Power BI base URL. Verify the endpoint’s pagination rules separately; do not assume Fabric continuation fields apply. Refresh is a write-like operational action: POST /groups/{groupId}/datasets/{datasetId}/refreshes. Refresh history and enhanced execution details have separate permissions and response semantics. In particular the group refresh-history documentation requires Write permission on the model, even though the method is GET.
Worked example 1 — report dependency inventory
The fixture contains two reports, both with datasetId equal to mock-m1. The dataset list contains one model with that ID. Compare IDs, not titles.
models = {m["id"] for m in fixture["datasets"]["value"]}linked = [r["id"] for r in fixture["reports"]["value"] if r.get("datasetId") in models]With fixture loaded from responses.json, predicted linked reports are mock-r1 and mock-r2. A missing ID should be recorded as unresolved, not deleted or automatically rebound.
Worked example 2 — accepted is not completed
The mock enhanced refresh transcript returns HTTP 202 with a Location ending in /refreshes/mock-refresh and an x-ms-request-id. No POST is executed. Record the operation identity and follow the documented execution-details endpoint for that refresh type. An in-progress enhanced refresh may return 202; a completed operation needs its terminal status inspected. Ordinary refresh history is a separate interface. After a successful refresh, reconcile model data and freshness; completion alone does not prove correct results.
Avoid duplicate refreshes
If the submission times out after the service may have accepted it, its outcome is unknown. Store a local intent identifier, target workspace/model, timestamp and returned correlation identifiers where available. Reconcile with authorized refresh status/history and target state before considering a new submission. A local idempotency record does not prove the service supports an idempotency-key header. Never trigger production refreshes in a learning exercise; this package contains no POST transport.
Practice and references
Use the synthetic metadata to count reports and resolve dataset IDs. Draw a state diagram distinguishing accepted, running, succeeded, failed and unknown. Identify why a read-only metadata user should not automatically be given refresh-history Write permission. See refresh in group, refresh history and execution details.