Updating Editor field on SharePoint Online using the CSOM with App Only Auth
I have the following issue. I work with CSOM and I want to update the Author and Editor field on a List Item object. The actual problem is that the Editor is not updated and the value is set to the SharePoint App user. The problem occurs after using the App Only Authentication. The following method is used to update Author, Editor, Creation Date and Modified Date. List<SP.ListItemFormUpdateValue> values = new List<SP.ListItemFormUpdateValue>(); foreach (ItemProperty property in properties) { property.AddPropertyToUpdateList(ctx, item, info, values); } IList<SP.ListItemFormUpdateValue> results = item.ValidateUpdateListItem(values, true, string.Empty); ctx.ExecuteQuery(); info.Log("<--// Called \'ValidateUpdateListItem\'. //-->"); // check for API-failures. CheckErrors(results); Do you have any ideas why this is not working for Editor but for Author-it works? I also tried to use the Update method to edit the Author and Editor, but this is also not working for the Author field. User user = service.Ctx.Web.EnsureUser("email address removed for privacy reasons"); ctx.Load(user); ctx.ExecuteQuery(); FieldUserValue userValue = new FieldUserValue(); userValue.LookupId =user.Id; item["Editor"] = userValue; item["Author"] = userValue; item.Update(); ctx.ExecuteQuery();3.9KViews0likes3CommentsMethod Not Found when running the application after some Windows updates
Hi everybody, After some Windows updates, I encountered a really annoying error. I don't have any compile errors, but when I run the application I get 'Method Not Found' error. Method not found: 'System.Collections.Generic.IList`1<Microsoft.SharePoint.Client.ListItemFormUpdateValue> Microsoft.SharePoint.Client.ListItem.ValidateUpdateListItem(System.Collections.Generic.IList`1<Microsoft.SharePoint.Client.ListItemFormUpdateValue>, Boolean, System.String)' I checked the ListItem class and the method is there. We are using theMicrosoft.SharePoint.Client, Version=15.0.0.0. Do you have any idea what could be the problem? Thanks, Cristina.Solved1.4KViews0likes1CommentRetryQuery not working after throttling
Hi everyone, We are using the recommended approach for throttling. Here is the method we are using to execute the requests: public void ExecuteQueryWithRetry(ClientContext ctx, int retryCount, int backOffInterval, ILog LOG) { DateTime startTimeStamp = DateTime.Now; try { int retryAttempts = 0; int retryAfterInterval = 0; bool retry = false; ClientRequestWrapper wrapper = null; LOG.Debug($"Client Context: {ctx.GetHashCode()}"); LOG.Debug($"Throttled : {Throttled}"); if (Throttled) { while (Throttled) { LOG.Debug("Still throttled..."); Thread.Sleep(100); } Thread.Sleep(new Random().Next(500)); LOG.Debug("Throttled finished"); } while (retryAttempts < retryCount) { try { if (retry && wrapper != null && wrapper.Value != null) { LOG.Debug("Execute request with wrapper value..."); ctx.RetryQuery(wrapper.Value); LOG.Debug("Execute request with wrapper value finished"); Throttled = false; return; } else { LOG.Debug("Execute request..."); ctx.ExecuteQuery(); LOG.Debug("Execute request finished"); Throttled = false; return; } } catch (WebException ex) { var response = ex.Response as HttpWebResponse; // Check for throttling if (response != null && (response.StatusCode == (HttpStatusCode)429 || response.StatusCode == (HttpStatusCode)503)) { Throttled = true; wrapper = (ClientRequestWrapper)ex.Data["ClientRequest"]; retry = true; string retryAfterHeader = response.GetResponseHeader("Retry-After"); if (!string.IsNullOrEmpty(retryAfterHeader)) { if (!Int32.TryParse(retryAfterHeader, out retryAfterInterval)) { retryAfterInterval = backOffInterval; } } else { retryAfterInterval = backOffInterval; } LOG.Warn($"We got throttled! Will back off for {retryAfterInterval} seconds."); } else { LOG.Debug(ex.StackTrace); throw; } } Thread.Sleep(retryAfterInterval * 1000); retryAttempts++; } throw new MaximumRetryAttemptedException($"Maximum retry attempts '{retryCount}' has been attempted."); } finally { if (LOG.IsDebugEnabled) { TimeSpan duration = DateTime.Now - startTimeStamp; LOG.Debug($"Executed CSOM query in [{duration.TotalMilliseconds.ToString("0.00")}] ms"); } } } We got the 429 error and after that we wait the recommended time until we execute again the request. The request is re-executed using the RetryQuery method. After the method is called, we got no error but the request is not executed. Do you have any ideas why we encounter this problem?1.7KViews0likes2CommentsRight User Permissions to use ListItem.GetUserEffectivePermissions method
I'm currently using a SharePoint account as a Service account to get files and share them in an application I'm working on usingCSOM. I filter the files according to the logged-in user to check if the user has no access to the file, then I hide it, to prevent him from trying to access it and get "Permission Denied" error. So, I usedListItem.GetUserEffectivePermissionsfor this issue, but I need to grant the user only the permissions he needs to access and make that check. I checked the official documentation ofListItem.GetUserEffectivePermissionsherebut unfortunately, I found no direct clue which permission does the job. So to recap what this service account needs to do is : Execute Search across all sharepoint files [SearchExecutor]. Get Login Name by Email usingUtility.ResolvePrincipal(to be used inGetUserEffectivePermissionsfunction). UseGetUserEffectivePermissionsto check if the logged-in User has permission to view the file. I'd really appreciate your help as I'm kind of new to SharePoint and I searched a lot but found no clue about what I need.1.4KViews0likes1CommentIs there any way to generate Sharing Link without breaking inheritance on file
Hello I had posted another question which i had posted here https://docs.microsoft.com/en-us/answers/questions/991989/create-sharing-link-using-csompnpframework.html?childToView=995490#comment-995490 We basically need unique link on document that does not change with a change in file location. While we got answer partly, it led to another question which is, is there any way to get sharing link of a document in SPO without breaking its inheritance. Basically to generate sharing link with option of "Peopke with existing access" ? Any way to have this by CSOM , Rest or Graph Api? There are couple of options in CSOM , Rest and Graph ApI (beta) ..however they all have option of anonymous or organization sharing link whi h caused breaking inheritance. We are going to gave large number of documents in library and unique permission will not help. https://docs.microsoft.com/en-us/graph/api/listitem-createlink?view=graph-rest-beta&tabs=http1.1KViews0likes2CommentsCSOM SystemUpdate() cannot update Editor field
In a SharePoint Online Document Library I've a file that is in published status (version x.0). I am updating various fields of this file with the listItem.SystemUpdate() command. I need this sort of update because is the only one that can be used on a published file that not increase the version. (UpdateOverrideVersion return an error on published documents) When I try to update the Editor fields this is not updated. (_currentItem is a File object) var user = _ctx.Web.EnsureUser(publishinfo.currentUser_email); _ctx.Load(user); _ctx.ExecuteQuery(); _currentItem.ListItemAllFields["Editor"] = user; _currentItem.ListItemAllFields.SystemUpdate(); _ctx.ExecuteQuery(); All other fields of the item can be updated. "Editor" and "Modified" are the only two that are not working. (Author for example is correctly updated in this way) Any idea? Thanks2.1KViews0likes1CommentExisting CSOM script modify from basic to modern authentication?
I have a big CSOM powershell script which is using basic authentication. This script is scheduled to run every day. This script is using credentials of a serviceaccount without MFA. We would like to disable basic authentication, but this script needs to be modified. I dont want to rewrite the whole CSOM script to Office Dev PnP Powershell because it is a big script. What is the easiest way to move from basic to modern authentication in a CSOM powershell script? See below a small part with authentication and some SPO logic: $lo_ClientContext = New-Object Microsoft.SharePoint.Client.ClientContext( https://myCompany.sharepoint.com/sites/test ) $lo_ClientContext.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials( Email address removed, myPassword ) $lo_ClientContext.ExecuteQuery() $ll_Lijst = $lo_ClientContext.Web.Lists.GetByTitle( "myList" ) $lo_ClientContext.Load( $ll_Lijst ) $lo_ClientContext.ExecuteQuery()712Views0likes0CommentsIs there any way to download recycle bins files and folder in SharePoint online using C# CSOM?
Hello, The main idea is that we wantto either download recycle bin files and folders using c# csom or restore to other library instead of original one. I already did research on this, nothing I found related to this. So if you know the concreate solution then please suggest. Thanks. BR/ Sid1.1KViews0likes0CommentsUsing App Password to login to SharePoint Online CSOM
Is it possible to use app passwords to login to SharePoint Online CSOM based scripts? We need to run scripts unattended and thus, using Pnp web login is not an option. Anyone know of workarounds to run CSOM scripts unattended. Our scripts need SharePoint administrator permissions as it uses user profile bulk update API.4.1KViews0likes1CommentIssue Setting Domains AllowList for Sharing in CSOM API
Hi all We found an issue trying to set allowed domains for sharing through CSOM. When setting the site property'sSharingDomainRestrictionMode to AllowList and setting theSharingAllowedDomainList all queries are executed without error, however when looking at the sharing settings in SharePoint the "Limit external sharing by domain." checkbox is checked, but the mode is set to "Don't allow sharing with users from these blocked domains" and no domains are in the list. The BlockList SharingDomainRestrictionMode works, and the SharingBlockedDomainList can be set.SharingDomainRestrictionMode None also works, only the AllowList does not work as intended. Does anyone have any idea what's going on here? var siteProperties = tenant.GetSitePropertiesByUrl(siteCollectionUrl, false); ctx.Load(siteProperties, s => s.SharingDomainRestrictionMode, s => s.SharingAllowedDomainList); ctx.ExecuteQueryRetry(); siteProperties.SharingDomainRestrictionMode = SharingDomainRestrictionModes.AllowList; siteProperties.SharingAllowedDomainList = domainString; siteProperties.Update(); ctx.ExecuteQueryRetry();Solved2.2KViews0likes4Comments