Forum Discussion
Anonymous
1 year agoNot applicable
How to use the PowerBI API to update an Azure Blob Storage datasource?
I've got a bunch of storage accounts, all holding similar data but from different environments, and I'm trying to generate a report per storage account in an automated fashion. I've got a PBIX file t...
Anonymous
1 year agoNot applicable
Hi Anonymous ,
You can refer the solution in the following link to solve it:
powerbi - How to update a data source via the API
$json =
@'
{{
"updateDetails": [{{
"datasourceSelector": {{
"datasourceType": "AnalysisServices",
"connectionDetails": {{
"server": "MY-OLD-SERVER-NAME",
"database": "MY-OLD-MODEL-NAME"
}},
"datasourceId": "{2}",
"gatewayId": "{3}"
}},
"connectionDetails": {{
"server": "{0}",
"database": "{1}"
}}
}}
]
}}
Or please update the codes as below by adding headers:
$body = @{
updateDetails = @(
@{
datasourceSelector = @{
datasourceType = "AzureBlob"
connectionDetails = @{
account = $DefaultStorageAccount
domain = "blob.core.windows.net"
}
}
connectionDetails = @{
account = $storageAccount.AccountName
domain = "blob.core.windows.net"
}
}
)
} | ConvertTo-Json -Compress
# Adding headers
$headers = @{
"Content-Type" = "application/json"
}
# Attempting to point the dataset to a new storage account. This is where the error is thrown.
Invoke-PowerBIRestMethod -Method Post -Url "datasets/$datasetId/Default.UpdateDatasources" -Headers $headers -Body $body
}
Best Regards