What exactly does ‘readable’ mean? My assumption is that Invoke-PowerBiRestMethod is a wrapper for Invoke-RestMethod. When Invoke-RestMethod receives a JSON response, it will automatically convert JSON to a Powershell object and then you are converting it back to JSON. If you are simply wanting to parse JSON to look a specific way or get something specific, then post an example of the JSON you are receiving, what is you are seeing and what the expected outcome would be.
I still have more to do with this, and I’m going a different route. I have to report the refresh history of PowerBI datasets. PowerBI has multiple workspaces, which in turn have multiple datasets. We want to grab the refresh history of the datasets, but we need to use the invoke REST API method to pull the data.
In order to do so, you need to grab the Workspace ID, then each Dataset ID under that workspace. The code I have pulls the datasets from 1 workspace and builds the URL needed to use in the invoke-powerbirestmethod:
if ($OutputArr.Count -gt 0) {
Write-Host($jOutput = Invoke-PowerBIRestMethod -Url $RefreshHistoryURL -Method Get | ConvertFrom-Json)
}
else {
Write-Host(“0”)
}
}
[/pre]
The first part of the loop works correctly and the output displays the URL needed for each dataset. However, I need to grab those URLs and build a command such as:
[pre]
$jOutput = Invoke-PowerBIRestMethod -Url $RefreshHistoryURL -Method Get | ConvertFrom-Json
[/pre]
For some reason, I’m having difficulty building this string for each dataset. Once each string is built, then I need to capture the values for the refresh history.
The loop you wrote only returns the refresh history for 1 dataset instead of the 4 under that workspace. It returns the necessary values, but many workspaces have multiple datasets.
I am not testing the code, just providing suggestions. If this were in a function, I’d use Write-Verbose and Write-Host to debug and see that it is looping through the datasets. I’d also see what is returned from the Invoke and if it was similar to your 3rd post, you’d need to get the value of that response. If there are multiple workspaces that have multiple datasets then it would be something like this: