Cha74
June 28, 2022, 9:32am
1
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 ?
Olaf
June 28, 2022, 11:21am
2
You assign the output of the command to a variable and use this variable where you need it.
Cha74
June 28, 2022, 11:26am
3
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
Olaf
June 28, 2022, 11:30am
4
Cha74:
doesn’t work
… 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
Cha74
June 28, 2022, 11:38am
5
I tried your code but it doesn’t work
Here is the error
Olaf
June 28, 2022, 11:49am
6
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?
Cha74
June 28, 2022, 11:55am
7
$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
Olaf
June 28, 2022, 12:00pm
8
What’s the output of this
"https://api.powerbi.com/v1.0/myorg/datasets/$($GETID.Id)/Default.UpdateParameters"
?
Cha74
June 28, 2022, 12:07pm
9
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
Olaf
June 28, 2022, 12:16pm
10
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?
Cha74
June 28, 2022, 12:23pm
11
Yes that’s why I don’t understand why it doesn’t work and it’s the same ID
Olaf
June 28, 2022, 12:25pm
12
Then I’m afraid I cannot help any further. Sorry.
Cha74
June 28, 2022, 12:27pm
13
Ok thanks for your help and your time