Tech
Forums
Jobs
Books
Events
Interviews
Live
More
Learn
Training
Career
Members
Videos
News
Blogs
Login
Sign Up
Ask Question
2
Reply
Add document set to library SharePoint Online
Thomas Pettinicchi
Mar 27 2017 8:59 AM
226
Reply
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 !
Upload Source Code
Select only zip and rar file.
Post
Reset
Cancel
Answers (
2
)
Next Recommended Forum
Converting an Asset library to Document library
Freeze row header in sharepoint list