powershellpowerbipowerbi-rest-api

How do I get a field from a JSON returned by Invoke-PowerBIRestMethod


So, I have a code like the following.

$x = Invoke-PowerBIRestMethod -Url 'datasets/<dataset_id>/refreshes' -Method Get

When I run it, the returned JSON data is like this,

{
  "@odata.context":"<some_url>/myorg/$metadata#refreshes","value":[
    {
      ....
    },
    {
      ...
    }
  ]
}

But if I try to get the field value, by typing $x.value, I get nothing. What mistake am I doing. I am new to PowerShell.


Solution

  • The output was in string form. I had to first convert it to JSON form by using the following command.

    $j = $x | ConvertFrom-Json

    Then I can see the value by typing $j.value