Get the dataset ID and add it to a POWER BI REST API command

I would like to retrieve the id of a dataset via this command :

Get-PowerBIDataset -Scope Organization -Name "REPORT FINANCE TEST"

Then, I would like to integrate it in this command instead of the hard number sequence.

$body ='{
  "updateDetails": [
    {
      "name": "WKS_NAME_PARAM",
      "newValue": "WKS"
    }
  ]
}'
Invoke-PowerBIRestMethod -Url "https://api.powerbi.com/v1.0/myorg/datasets/1cd873be-50b9-4b71-a35f-a58b7dd9f6c2/Default.UpdateParameters" -Method Post -Body $body

Can anyone help me ?

You assign the output of the command to a variable and use this variable where you need it.

I tried that but it doesn’t work

$GETID = Get-PowerBIDataset -Scope Organization -Name "REPORT FINANCE DEV"

$body ='{
  "updateDetails": [
    {
      "name": "WKS_NAME_PARAM",
      "newValue": "WKS"
    }
  ]
}'

Invoke-PowerBIRestMethod -Url "https://api.powerbi.com/v1.0/myorg/datasets/$GETID.Id/Default.UpdateParameters" -Method Post -Body $body

… is not helpful at all. What happens?

Did you try to use a subexpression?

Invoke-PowerBIRestMethod -Url "https://api.powerbi.com/v1.0/myorg/datasets/$($GETID.Id)/Default.UpdateParameters" -Method Post -Body $body

I tried your code but it doesn’t work
Here is the error

Please do not post images of code. That’s not helpful at all. Instead post the plain text formatted as code.

Since your error message does not show the complete URI I cannot say what’s wrong. What have you tried to make sure the output of $($GETID.Id) is what you expected?

$GETID = Get-PowerBIDataset -Scope Organization -Name "REPORT FINANCE DEV"



$body ='{
  "updateDetails": [
    {
      "name": "WKS_NAME_PARAM",
      "newValue": "WKS"
    }
  ]
}'

Invoke-PowerBIRestMethod -Url "https://api.powerbi.com/v1.0/myorg/datasets/$($GETID.Id)/Default.UpdateParameters" -Method Post -Body $body

What’s the output of this

"https://api.powerbi.com/v1.0/myorg/datasets/$($GETID.Id)/Default.UpdateParameters"

?

The result of this command is to modify the parameters of a dataset

POST https://api.powerbi.com/v1.0/myorg/datasets/{datasetId}/Default.UpdateParameters

:roll_eyes:

In your initial question you posted this:

Invoke-PowerBIRestMethod -Url "https://api.powerbi.com/v1.0/myorg/datasets/1cd873be-50b9-4b71-a35f-a58b7dd9f6c2/Default.UpdateParameters" -Method Post -Body $body

It obviously contains the dataset ID you’re after, right?

If you output this

"https://api.powerbi.com/v1.0/myorg/datasets/$($GETID.Id)/Default.UpdateParameters"

it should have the dataset ID. Do both IDs look the same?

Yes that’s why I don’t understand why it doesn’t work and it’s the same ID

Then I’m afraid I cannot help any further. Sorry.

Ok thanks for your help and your time