Showing results for 
Search instead for 
Did you mean: 
Ashu2021 Helper I
Helper I

Data Refresh with PowerShell

Hi All


I am trying to write a code in powershell to refresh my dataset. I am using below code


$groupID = "********"

$datasetID = "********"
$clientId = "************"


# Get the auth token from AAD
$token = Get-PowerBIAccessToken


# properly format groups path
$groupsPath = ""
if ($groupID -eq "me") {
$groupsPath = "myorg"
} else {
$groupsPath = "myorg/groups/$groupID"


# Refresh the dataset
$uri = "$groupsPath/datasets/$datasetID/refreshes"
Invoke-RestMethod -Uri $uri -Headers $token -Method Post -Verbose


However, getting below mentioned error


Invoke-RestMethod : The remote server returned an error: (415) Unsupported Media Type.
At line:53 char:1
+ Invoke-RestMethod -Uri $uri -Headers $token -Method Post -Verbose
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand


Please suggest, how I can resolve this error or is there any new way to refresh my dataset

Helpful resources

New Ranks Launched March 24th!

New Ranks Launched March 24th!

The time has come: We are finally able to share more details on the brand-new ranks coming to the Power BI Community!

‘Better Together’ Contest Finalists Announced!

‘Better Together’ Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

Arun 'Triple A' Event Video, Q&A, and Slides

Arun 'Triple A' Event Video, Q&A, and Slides

Missed the Arun 'Triple A' event or want to revisit it? We've got you covered! Check out the video, Q&A, and slides now.

Top Solution Authors