I am trying to retrieve data from a specific Analytics View in Azure DevOps using Python. I am able to list all available views, including custom shared/private views, but I cannot fetch the actual data from any specific view using its ID.
What I Have Tried Getting the list of available views works: I successfully get a list of custom views using this API:
import requests
import pandas as pd
from requests.auth import HTTPBasicAuth
# Azure DevOps Configuration
organization = "xxx"
project = "xxx"
personal_access_token = "xxx"
# API to list Analytics Views
url = f"https://analytics.dev.azure.com/{organization}/{project}/_apis/analytics/views?api-version=7.1-preview.1"
auth = HTTPBasicAuth("", personal_access_token)
# Make API request
response = requests.get(url, auth=auth)
if response.status_code == 200:
data = response.json()
df = pd.DataFrame(data["value"])
print(df[["id", "name", "description"]]) # Show relevant columns
else:
print(f"Error fetching views: {response.status_code} {response.text}")
Problem: After getting the view ID, I try to fetch data using:
view_id = "a26xxxxx-xxxx-xxx-xxxx-xxxxxxxx94b0" # Example View ID
url = f"https://dev.azure.com/{organization}/{project}/_apis/analytics/views/{view_id}/data?api-version=7.1-preview.1"
response = requests.get(url, auth=auth)
if response.status_code == 200:
data = response.json()
df = pd.DataFrame(data["value"])
print(df.head())
else:
print(f"Error fetching data from view: {response.status_code} {response.text}")
Even though the view ID is correct (verified from the list API), the request fails.
Error fetching data from view: 404
The controller for path '/xxx/_apis/analytics/views/a26xxxxx-xxxx-xxx-xxxx-xxxxxxxx94b0/data' was not found or does not implement IController.
What I Tried Debugging
What I Need Help With
It doesn't support directly retrieving the result of an Analytics view using its view ID via the Azure DevOps API.
Power BI can display the results of an Analytics view from Azure DevOps because it uses the Azure DevOps Data Connector, which allows Power BI to directly connect to Analytics views. These views are essentially predefined OData queries that fetch specific sets of data from Azure DevOps. Once connected, Power BI imports the data from the Analytics view into its environment, uses the data to create various reports and visualizations.
It's suggested that you construct OData queries to fetch the data you need from the Analytics service. This involves manually creating queries that replicate the filters and criteria of your Analytics view.