Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
h4tt3n
Resolver II
Resolver II

Automatic report upload through API erratic behaviour - looking for guidelines

I have been working professionally with measurement data vissulatisation in PBI for over a year, and one of my job tasks is to manage an ever-growing number of reports for our company. For this reason we have moved from manually managing reports through the PBI service GUI to automatic management via a number of PowerShell scripts. This includes automatic upload of tens of reports at a time.

 

In pseudocode, this  is what the script attempts to do:

 

for each customer account in our DB:

Check if report exists

If not:

upload empty report template

Set parameters that pair report with customer account

Set refresh schedule

Refresh dataset

 

Unfortunately, PBI service responds in an erratic and unpredictable way when attempting automatic report upload. It appears that often the parameters does not get set, making the report unable to retrieve customer data. I have added a 10 sec wait command between every requests to give the PBI service API and DB some breathing space, but this doesn't seem to improve behaviour.

I am looking for guidelines on how to manage multiple report upload through API calls without running into these challenges.

Cheers, Mike

 

 

2 REPLIES 2
V-lianl-msft
Community Support
Community Support

How do you set parameters and retrieve data?

Could you provide more information to let me know your scenario

I retrieve data from Azure T-SQL DB using a SQL query. I set parameters with an API call, using the below function. It works most of the time, but fails sometimes for non-apparetn reasons. I have improved the success-rate by increasing the wait time after the report is uploaded, before updating parameters. 

Also, I have noticed a peculiar tencency; older accounts (4-5 years) tend to fail more often than accounts that have recently been created ( < one year).

 

function UpdateParameter
{
    # This operation is only supported for the dataset owner. Call TakeOverDataset()
    
    [CmdLetBinding()]
    param 
    ( 
        [Parameter(Mandatory=$true, Position=0)] [string] $datasetId, 
        [Parameter(Mandatory=$true, Position=1)] [string] $parameterName, 
        [Parameter(Mandatory=$true, Position=2)] [string] $parameterNewValue 
    )
    
    $url = "https://api.powerbi.com/v1.0/myorg/datasets/$datasetId/Default.UpdateParameters"

    $body = '{ "updateDetails": [ { "name": "'+$parameterName+'", "newValue": "'+$parameterNewValue+'" } ] }'

    Invoke-PowerBIRestMethod -Url $url -Body $body -Method POST

}

 

 

Cheers, Mike

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.