Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago

[REST API] Datasets Take Over: Positional Parameter cannot be found that accepts argument 'Method'

Getting the following error when trying to take over dataset using this REST API: https://docs.microsoft.com/en-us/rest/api/power-bi/datasets/take-over-in-group

 

 

Following is my code:


#Login using Service Principal
#-------------------------------
cls
$applicationId = "XXXXX"
$clientsec = "XXXXX" | ConvertTo-SecureString -AsPlainText -Force #
$tenantId = "XXXXX"
$resource = "https://analysis.windows.net/powerbi/api"

$credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $applicationId, $clientsec
Connect-PowerBIServiceAccount -ServicePrincipal -Credential $credential -TenantId $tenantId

# Get token
#-------------------------------
$token = Get-PowerBIAccessToken -AsString



# Building Rest API header with authorization token
#-------------------------------
$authHeader = @{
'Content-Type'='application/json'
'Authorization'=$token
}

#Group and Dataset Parameters
#-------------------------------
$group= "xxxxx" #workspace ID
$dataset= "xxxxxx" #dataset ID


# POST body
#-------------------------------
$postParams = @{
"datasetId" = "$dataset"
}
$jsonPostBody = $postParams | ConvertTo-JSON

$Url = "https://api.powerbi.com/v1.0/myorg/groups/$group/datasets/$dataset/Default.TakeOver"


## Take Over DataSet
#-------------------------------
Invoke-PowerBIRestMethod -Url $Url -Headers $authHeader -Body $jsonPostBody Method -POST -Verbose

 The Service Principal has the following permissions:

 

What am I missing? Please help! Thanks in advance.

 

8 Replies

  • Anonymous instead of 

     

    Method -Post

     

    you need 

     

    -Method POST

    • Anonymous's avatar
      Anonymous
      Not applicable

      Getting the same error after replacing -POST with POST:

       

       

      • lbendlin's avatar
        lbendlin
        Super User

        Please read my reply again.  Use -Method  (note the dash)