4

Am new to Tridion Core Service, can someone help me with the sample code to read and get the Component from Tridion using Core Service?

7

Welcome to Tridion

Core Service is a .Net web service API, allows you to interact with the CMS from another machine than the CMS server itself and before jumping on writing CURD operation using Tridion Core service I would recommend to you , please go through to SDL documentation and learn about Tridion Core Service ,there you will code snippets as well that will help you in writing CRUD operation using Core service

About Core Service https://docs.sdl.com/LiveContent/content/en-US/SDL%20Tridion%20Sites-v2/GUID-9E83FE0C-F650-451F-BEB3-7960A4925D90

READ operation https://docs.sdl.com/LiveContent/content/en-US/SDL%20Tridion%20Sites-v2/GUID-973CC313-C411-4737-8263-F04D4378331C

| improve this answer | |
  • sample code for getting component ? – Jeevitha Feb 26 at 4:09
3

You may also want to check out the 'Core Service Recipies' section of the Tridion Cookbook here: https://github.com/TridionPractice/tridion-practice/wiki/CookbookDocumentation

There are some excellent examples in there to get you started.

| improve this answer | |
0

You can read all components using the core service client,

static void RetrievingItems(CoreServiceClient client)
{
    var filterdata = new RepositoryItemsFilterData();
    filterdata.Recursive = true;
    filterdata.ItemTypes = new[] { ItemType.Component };

    XElement resultxml = client.GetListXml(_publicationId, filterdata);
    if (resultxml != null)
    {
        foreach (var component in resultxml.Elements())
        {
            var compData = (ComponentData)client.Read(component.Attribute("ID").Value, 
                                                      new ReadOptions());
            //Do whatever you want with componnetData
        }
    }
}
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.