Forum Discussion

RamyaRascher's avatar
RamyaRascher
Regular Visitor
3 years ago
Solved

Difference between via Api and via Enhanced Api

I am trying to deploy reports to workspaces using PowerShell scripts. Our organization uses the same pbix file skeleton and changes to client datasource in their respective workspaces. We achieve thi...
  • Anonymous's avatar
    Anonymous
    3 years ago

    Hi RamyaRascher ,

    The Power BI REST API is a REST-based API that provides programmatic access to Dashboard resources such as Datasets, Tables, and Rows in Power BI. The Enhanced API is a new version of the Power BI REST API that provides additional functionality and performance improvements over the previous version. The Enhanced API is currently in preview and is available to use alongside the existing Power BI REST API.

     

    To clear the data in the partitions of a Power BI dataset using PowerShell, you can use the Invoke-RestMethod cmdlet in PowerShell to call the Power BI REST API and send a DELETE request to the partitions endpoint of the dataset. Here is an example PowerShell script that clears the data in the partitions of a dataset:

    $token = Get-PowerBIAccessToken
    $authHeader = @{ 'Authorization' = "Bearer $token" }
    $datasetId = '<your dataset ID>'
    $partitionsEndpoint = "https://api.powerbi.com/v1.0/myorg/datasets/$datasetId/partitions"
    Invoke-RestMethod -Uri $partitionsEndpoint -Headers $authHeader -Method DELETE

    This script first gets an access token for the Power BI REST API using the Get-PowerBIAccessToken cmdlet. It then constructs an authorization header using the access token. The script then specifies the dataset ID and constructs the partitions endpoint URL. Finally, the script sends a DELETE request to the partitions endpoint using the Invoke-RestMethod cmdlet to clear the data in the partitions of the dataset。

    Best Regards