3

I was looking for a way that how can I fetch all the categories from Tridion using Categoriesdata. I was trying like below, but its showing error.

CoreServiceSession client = new CoreServiceSession();
SessionAwareCoreServiceClient csClient = client.GetClient();
ReadOptions readoption = new ReadOptions();
CategoriesFilterData filter = new CategoriesFilterData();
XElement xml = csClient.GetSystemWideList(filter);
Mark Amery
158k94 gold badges435 silver badges477 bronze badges
asked Aug 23, 2012 at 4:11
1
  • I noticed in this and previous code samples that you create a CoreServiceSession object. Just out of curiosity: what is that class and where does it come from? You don't seem to use it. Commented Aug 23, 2012 at 11:24

1 Answer 1

9

You need to use GetListXml instead of GetSystemWideList and specify the publication ID from which you want to retrieve the categories:

CategoriesFilterData filterData = new CategoriesFilterData();
XElement resultXml = client.GetListXml(publicationId, filterData);

GetSystemWideList is usually for retrieving stuff that is system wide and not bound to just 1 publication, like PublicationTargets and MultimediaTypes

You could however also try a Search query, like so:

SearchQueryData filter = new SearchQueryData(); 
filter.ItemTypes = new ItemType[] { ItemType.Category }; 
IdentifiableObjectData[] results = client.GetSearchResults(filter);
foreach (IdentifiableObjectData obj in results)
{
 Console.WriteLine(String.Format("{0} - {1}", obj.Title, obj.Id));
}
answered Aug 23, 2012 at 6:24
Sign up to request clarification or add additional context in comments.

3 Comments

Thanks Reinder, but what if i need to get all the catagories from tridion not from a specific publication.
Ah, OK. you could try using SearchQueryData and search within tridion.
like so: SearchQueryData filter = new SearchQueryData(); filter.ItemTypes = new ItemType[] { ItemType.Category }; filter.BaseColumns = ListBaseColumns.Extended; IdentifiableObjectData[] results = client.GetSearchResults(filter);

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.