Trying to Reference a Featured Item by String Index in an APIList of Featured Items returns System.NotSupportedException

Trying to Reference a Featured Item by String Index in an APIList of Featured Items returns System.NotSupportedException

This question is answered

I was attempting to reference a featured item in a list of featured items by index, but was getting a velocity script error.  Is this not possible or am I calling an incorrect method?  The Api Documentation in the control panel makes it appear this should work..

#set ($group = $core_v2_group.Current)

#if($group.Id == $core_v2_group.Root.Id)
   #set ($features = $core_v2_feature.List("%{ Count = 2 }"))
#else
   #set ($features = $core_v2_feature.List("%{ GroupId = $group.Id, Count = 2 }"))
#end
$features.Get('0').Title

$features.Get('0').Title
This is the line that is causing the problems.. 

Invocation of method 'Get' in <namespace> threw an exception.  System.NotSupportedException: Index by string is only supported by ApiList<T> where T implements IKeyedApiEntity

Verified Answer
  • I think that is just a limitation of the documentation not knowing that Feature does not implement IKeyedApiEntity.

    In the mean time, you can use $features.get_Item(0).Title to retrieve items from the ApiList by index

All Replies
  • I think that is just a limitation of the documentation not knowing that Feature does not implement IKeyedApiEntity.

    In the mean time, you can use $features.get_Item(0).Title to retrieve items from the ApiList by index

  • Thanks Mathew.