Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Unexpected list type" exception when invoking ISessionAwareCoreService.GetList()

Tags:

tridion

I am invoking the Tridion 2011 SP1 core service via the shipped client assembly. When I attempt to list the contents of a publication, I get an exception.

The code (simplified) looks like this:

ItemsFilterData filter = new Tridion.ContentManager.CoreService
                     .Client.RepositoryItemsFilterData.RepositoryItemsFilterData();
filter.ItemTypes = new ItemType[] { 
    ItemType.Folder, 
    ItemType.StructureGroup 
};
filter.Recursive = false;                        

IEnumerable<IdentifiableObjectData> childItems = core.GetList("tcm:0-15-1", filter);

Note: the variable "core" refers to an ISessionAwareCoreService which I can successfully use to call, for example core.GetSystemWideList()

When .GetList is invoked, I get the following exception:

System.ServiceModel.FaultException`1 was unhandled
  Message=Unexpected list type: 
     Tridion.ContentManager.Data.ContentManagement.RepositoryItemsFilterData.

What are the possible causes of this problem? Can you suggest a good general approach for interpreting this kind of message?

like image 572
Dominic Cronin Avatar asked May 01 '12 13:05

Dominic Cronin


1 Answers

You can't get the direct children of a Publication using GetList. Instead you should just load the PublicationData with a client.Read and then access the RootFolder and RootStructureGroup on that.

PublicationData pub = (PublicationData)core.Read("tcm:0-1-1", new ReadOptions());
string rootFolder = pub.RootFolder.IdRef;
string rootSG = pub.RootStructureGroup.IdRef;

Alternatively you can call GetListXml with your RepositoryItemsFilterData and extract the items from the XML yourself.

XElement listResult = core.GetListXml(parent.ID, filter);
like image 114
Frank van Puffelen Avatar answered Oct 22 '22 16:10

Frank van Puffelen