TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Thomas Pettinicchi
NA
18
670
Add document set to library SharePoint Online
Mar 27 2017 8:59 AM
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 !
Reply
Answers (
2
)
Converting an Asset library to Document library
Freeze row header in sharepoint list