sharepoint-clientobject

Create CSOM ClientContext with re-usability like singleton pattern

Deadly 提交于 2020-02-29 06:45:04
问题 The bounty expires in 4 days . Answers to this question are eligible for a +50 reputation bounty. Amna wants to draw more attention to this question: I need the accurate answer which will highlight how can making a static ClientContext object for reusability can affect? and what is the expiry of this context as when it is required to be refreshed? I have multiple methods being called on different user actions which is using ClientContext . Creating it on every method execution was causing

Namespace 'SharePoint' does not exist in the namespace 'Microsoft'

自闭症网瘾萝莉.ら 提交于 2020-01-12 07:58:18
问题 So I am starting to learn C#, like literally just started learning, and coming from a Java background, it doesn't look too bad. However, I have a question. I am following THIS tutorial on using the client-object model. And just starting from the top, I added the references, but using Microsoft.SharePoint.Client; keeps giving me the error that "the namespace 'SharePoint' does not exist in the namespace 'Microsoft', but I clearly see it on the right side panel. So looking at the instructions,

Programmatically get ListItemVersion using client object model SharePoint 2010

巧了我就是萌 提交于 2020-01-01 05:01:46
问题 I have a scenario where I have to move all my data in a SharePoint 2010 list (name= "VersionTestList") to a SQL server database. Since versioning is enabled in the list, I want to move the previous version details too. Anyway I was able to move the latest item, but unfortunately I am not able to get the previous version data. I have tried this using Client Object Model and able to get the versions, but not able to get the ListItem of that corresponding version. Please find below the code

Web.GetFileByServerRelativeUrl throws “Value does not fall within expected range”

。_饼干妹妹 提交于 2019-12-23 07:03:48
问题 I have a SP Online site where I store Documents, I have no issues adding/retrieving documents but in the delete flow I get an error during retrieval of a File object. public static void DeleteDocument() { using (ClientContext ctx = ClientContextFactory.Create("https://my-sponline-site.sharepoint.com/sites/documentsite")) { Web web = ctx.Web; ctx.Load(web); ctx.ExecuteQuery(); string relativeUrl = "/Documents/images.jpg"; File file = web.GetFileByServerRelativeUrl(relativeUrl); ctx.Load(file);

Client-side SharePoint PowerShell - Get list items - The collection has not been initialized

与世无争的帅哥 提交于 2019-12-23 05:14:25
问题 On SharePoint 2013, I am trying to get list items, with client-side SharePoint PowerShell. Even for field Id or Title, I encounter this error: The collection has not been initialized. I don't know how to include fields. I find many exemples in C# or JavaScript but none in client side powershell. Here is my code (it returns correctly the number of items): Function New-Context([String]$WebUrl) { $context = New-Object Microsoft.SharePoint.Client.ClientContext($WebUrl) $context.Credentials =

Sharepoint Client Object Model The property or field has not been initialized

≡放荡痞女 提交于 2019-12-23 04:41:20
问题 I have a C# program that manages Sharepoint lists using the Sharepoint Client Object Model. Occasionally we will have server issues which will prevent the program from accessing the sharepoint server. I am using a helper class to run the ExecuteQuery method and have exception handling to continue to execute until there is no exception. private void ExecuteContextQuery(ref ClientContext siteContext) { int timeOut = 10000; int numberOfConnectionErrors = 0; int maxNumberOfRetry = 60; while

Access denied office 365 / SharePoint online with Global Admin account

梦想与她 提交于 2019-12-21 05:15:11
问题 I am going crazy since two days solving an issue. The problem is; I am making a console APP which is talking to SharePoint Online using global admin account (One which was specified as admin while making a new subscription). What I am trying to achieve is, I want to add a custom action using CSOM to each site collection and subsite of office 365. That code works fine except on the root site collection which is pre-created by office 365 while signing up (i.e. https://xyz.sharepoint.com) For

How to grant user permission to certain folders using Client Object Model?

邮差的信 提交于 2019-12-19 04:48:10
问题 So far I am able to grant user certain permission with the following code: ClientContext context = new ClientContext("http://myRealURL"); Principal user = context.Web.EnsureUser(@"myLoginAccout"); RoleDefinition readDef = context.Web.RoleDefinitions.GetByName("Read"); RoleDefinitionBindingCollection roleDefCollection = new RoleDefinitionBindingCollection(context); roleDefCollection.Add(readDef); RoleAssignment newRoleAssignment = context.Web.RoleAssignments.Add(user, roleDefCollection);

How to grant user permission to certain folders using Client Object Model?

会有一股神秘感。 提交于 2019-12-19 04:47:47
问题 So far I am able to grant user certain permission with the following code: ClientContext context = new ClientContext("http://myRealURL"); Principal user = context.Web.EnsureUser(@"myLoginAccout"); RoleDefinition readDef = context.Web.RoleDefinitions.GetByName("Read"); RoleDefinitionBindingCollection roleDefCollection = new RoleDefinitionBindingCollection(context); roleDefCollection.Add(readDef); RoleAssignment newRoleAssignment = context.Web.RoleAssignments.Add(user, roleDefCollection);

SharePoint Foundation 2010 Client Object Model Authentication

冷暖自知 提交于 2019-12-13 14:33:20
问题 I want to implement a custom logging by passing authentication information, as shown in below reference links: http://blogs.msdn.com/b/cjohnson/archive/2011/05/03/authentication-with-sharepoint-online-and-the-client-side-object-model.aspx http://msdn.microsoft.com/en-us/library/hh147177(v=office.14).aspx I'm using below code but it does not automatically login instead it just popup the login window to enter username and password. I want to automatically log in by passing the credentials pro