AnsweredAssumed Answered

Rest API Get Snapshot Collection: Cannot index into a null array.

Question asked by Jeffrey Adams on Apr 8, 2016
Latest reply on Apr 14, 2016 by Jeffrey Adams

Hi All.

 

I have a powershell script using the REST API to refresh dev/qa environments.

The refresh has been working great for some time.  All of the sudden today I had 2 machines fail with  Cannot index into a null array.

Here is the snippet of code:

 

$prod_array = @();

$ProdVolume_array = @();

$topsnapshot_array = @();

$uri = "https://" + $ArrayIP + "snapshot_collections/detail"

$snaplist = Invoke-RestMethod -Uri $uri -Method get -Header $header

$prod_array += $snaplist.data 

$ProdVolume_array = $prod_array | select snapshots_list, name, creation_time |where-object name -like $ProdVolumeCollection* | sort-object -Property creation_time -descending

$topsnapshot_array = $ProdVolume_array[0].snapshots_list


$snaplist does have information in it.  when I look at $prod_array and $ProdVolume_array I see nothing.  I don't understand why.

 

Thanks,

Jeff

Outcomes