1

I'm trying to create a list in SharePoint 2013 using CSOM. The problem is that when the query is executed it says that it couldn't find any matches. I have checked, and the list template (Pest) is on the List Template Gallery.

 ClientContext context = new ClientContext(SiteURL);
        context.Credentials = credentials;
        var site = context.Web;
        context.Load(site, s => s.ListTemplates);
        context.ExecuteQuery();
        var listCreationInfo = new ListCreationInformation
        {
            Title = "My Jobs",
            Description = "This is the job list description"
        };
        var listTemplate = site.ListTemplates.First(template => template.Name == "Pest");
        listCreationInfo.TemplateFeatureId = listTemplate.FeatureId;
        listCreationInfo.TemplateType = listTemplate.ListTemplateTypeKind;
        site.Lists.Add(listCreationInfo);
        context.ExecuteQuery();

I also implemented a function to retrieve all list templates on my site, but it won't show me the Pest template. I have tried all day without success, and checked all the questions.

  • var site = context.Web - is it really the root site of the site collection? list templates live at site collection level not at sub sites level! – Vamsi K K Sep 24 '15 at 11:49

Your Answer

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

Browse other questions tagged or ask your own question.