Thomas Pettinicchi
asked on
Add document set to library SharePoint Online
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("Ev ent");
ContentTypeCollection listContentTypes = formLib.ContentTypes;
ContentTypeId dsCtId = new ContentTypeId();
clientContext.Load(listCon tentTypes, types => types.Include(type => type.Id, type => type.Name, type => type.Parent));
var result = clientContext.LoadQuery(li stContentT ypes.Where (c => c.Name == "Events"));
clientContext.ExecuteQuery ();
ContentType docsetCT = result.First();
ContentTypeId ctid = docsetCT.Id;
DocumentSet.Create(clientC ontext, 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.ServicePassw ord)
{
securePassword.AppendChar( c);
}
var onlineCredentials = new SharePointOnlineCredential s(Configur ation.Serv iceUserNam e, securePassword);
var context = new ClientContext(Configuratio n.ServiceS iteUrl);
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 ...
My final goal is to host on azure a web service where people can upload document set with simple HTTP POST request, but i dont know if it's possible ...
Thanks a lot !
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("Ev
ContentTypeCollection listContentTypes = formLib.ContentTypes;
ContentTypeId dsCtId = new ContentTypeId();
clientContext.Load(listCon
var result = clientContext.LoadQuery(li
clientContext.ExecuteQuery
ContentType docsetCT = result.First();
ContentTypeId ctid = docsetCT.Id;
DocumentSet.Create(clientC
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.ServicePassw
{
securePassword.AppendChar(
}
var onlineCredentials = new SharePointOnlineCredential
var context = new ClientContext(Configuratio
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 ...
My final goal is to host on azure a web service where people can upload document set with simple HTTP POST request, but i dont know if it's possible ...
Thanks a lot !
I think you have a syntax error in line 7: c.Name == "Events"
This question needs an answer!
Become an EE member today
7 DAY FREE TRIALMembers can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.