Hello,
I'm trying to create a document set in a document library SharePoint online.
I have a special document set for this : Events
I need to create this event in à webservice Azure, and i try with this code :
- ClientContext clientContext = GetonlineContext();
- Web spWeb = clientContext.Web;
- var formLib = spWeb.Lists.GetByTitle("Event");
- ContentTypeCollection listContentTypes = formLib.ContentTypes;
- ContentTypeId dsCtId = new ContentTypeId();
- clientContext.Load(listContentTypes, types => types.Include(type => type.Id, type => type.Name, type => type.Parent));
- var result = clientContext.LoadQuery(listContentTypes.Where(c => c.Name == "Events"));
- clientContext.ExecuteQuery();
- ContentType docsetCT = result.First();
- ContentTypeId ctid = docsetCT.Id;
- DocumentSet.Create(clientContext, formLib.RootFolder, value.name, ctid);
- clientContext.ExecuteQuery();
- private class Configuration
- {
- public static string ServiceSiteUrl = "https://****.sharepoint.com";
- public static string ServiceUserName = "*****";
- public static string ServicePassword = "******";
- }
- static ClientContext GetonlineContext()
- {
- var securePassword = new SecureString();
- foreach (char c in Configuration.ServicePassword)
- {
- securePassword.AppendChar(c);
- }
- var onlineCredentials = new SharePointOnlineCredentials(Configuration.ServiceUserName, securePassword);
- var context = new ClientContext(Configuration.ServiceSiteUrl);
- context.Credentials = onlineCredentials;
- return context;
- }
But when i execute, there is no document add to the library.
Can you please help me ? I'm lost ...
Thanks a lot !