Quantcast
Channel: Microsoft Online: SharePoint Online forum
Viewing all articles
Browse latest Browse all 10096

Uploading file into Share Point online with a outlook live id using C#

$
0
0

HI,

I need to upload file into share point online (2013) using C# with a live id test@outlook.com. I am using the below code                                  

    string siteUrl = "https://microsoft.sharepoint.com/xxx/yyyy";
            string filePath = Console.ReadLine();

            ClientContext context = new ClientContext(siteUrl);

            SecureString passWord = new SecureString();

            foreach (var c in "password") passWord.AppendChar(c);
            context.Credentials = new SharePointOnlineCredentials("test@outlook.com", passWord);

            Web site = context.Web;

            //Get the required RootFolder
            string barRootFolderRelativeUrl = "Shared Documents/abc/Main";
            Folder barFolder = site.GetFolderByServerRelativeUrl(barRootFolderRelativeUrl);

            Folder currentRunFolder = site.GetFolderByServerRelativeUrl(barRootFolderRelativeUrl);
            FileCreationInformation newFile = new FileCreationInformation { Content = System.IO.File.ReadAllBytes(filePath), Url = System.IO.Path.GetFileName(filePath), Overwrite = true };
            currentRunFolder.Files.Add(newFile);
            currentRunFolder.Update();

            context.ExecuteQuery(); 

But I am getting below exception:

An unhandled exception of type 'Microsoft.SharePoint.Client.IdcrlException' occurred in Microsoft.SharePoint.Client.Runtime.dll

Additional information: The Login server cannot issue the requested compact encrypted ticket because a Data Encryption Key (DEK) has not been uploaded to the site.

Please help me to resolve this.

Thanks,

Trinadh


Viewing all articles
Browse latest Browse all 10096

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>