Unable to delete item via List service - sharepoint

I have a console job that does some comparison on documents in a SharePoint library, and then deletes some of the documents.
However, the deletion fails for some documents, with the below error:
<ErrorCode>0x80070005</ErrorCode>
<ErrorText>Access denied.
You do not have permission to perform this action or access this resource.</ErrorText>
What could be the issue?
I have checked the document library, and the individual documents, and verified that the concerned account has delete permissions. In fact, many other documents are getting deleted from the same library.
It cannot be that somebody else has the document open somewhere; I have not been able to delete some documents for over an year.
p.s. the delete method is called via listService.UpdateListItems(libraryname, XML)

Related

Firestore - Cloud functions - Get uid of user who deleted a document

I am trying to get the UID within an onWrite cloud function of any authenticated user who deletes a document in firestore (not the real time database which doesn't have this issue). The reason is... I am trying to create a log of all actions performed on documents in a collection. I have to use cloud functions as the client could hypothetically create/edit/delete a document and then prevent the corresponding log entry from being sent.
I have seen in other stackoverflow questions like:
Firestore - Cloud Functions - Get uid
Getting the user id from a Firestore Trigger in Cloud Functions for Firebase?
That firestore will not include any auth data for firestore in the onWrite function, and that the accepted workaround is to have fields like updated_by, created_by, created_at, updated_at in the document being created/updated which are verified using firebase permissions. This is great for documents being inserted or updated, but deleted documents in onWrite cloud functions only have change.before data, and no change.after data, meaning you have no way to see who deleted the document, and at best who updated the document last before deletion.
I am in the middle of trying out some work arounds as follows (but they have serious detractors):
Sending an update to a document right before it is to be deleted. Issues -> Might have timing issue, debounce issues, requires messy permissions to ensure that a document is only deleted if it has the proceeding update.
Updating it with a field that tags it for deletion and watching for this tag in a cloud function that then does the deleting. Issues -> leads to a very noticeable lag before the item is deleted.
Does anyone have a better way of doing something like this? Thanks!
Don't delete the document at all. Just add a field called "deleted", set it to true, and add another field with the UID of the user that deleted it. Use these new fields in your queries to decide if you want to deal with deleted documents or not for any given query.
Use a different document in a separate collection that records deletions. Query that collection whenever you need to know if a document has been deleted. Or create a different record in a different database that marks the deletion.
There are really no other options. Either use the existing document or create a new document to record the change. Existing documents are the only things that can be queried - you can't query data that doesn't exist in Firestore.

Get user performing action in Sharepoint CSOM

We are using SharePoint client object model (CSOM) and REST/OData endpoints to retrieve/manage data on sharepoint.
Is there anyway to get information on the user performing the MOVE on a file (for example, move file from folder A to folder B within same site collection)? When I use this REST API call before and after the move, Author and Editor remains the same even though a completely different user moved the file from folder A to folder B. SPChangeItem does not seem to have any members with this information either.
https://{site_url}/_api/web/GetFileByServerRelativePath(DecodedUrl=#fileUrl)?$expand=Author,ListItemAllFields,ListItemAllFields/ParentList,ListItemAllFields/ParentList/ParentWeb&$select=UniqueId,Author/LoginName,Author/Email,Author/Id,Editor/LoginName,Editor/Email,Name,UserName,ServerRelativeUrl,MajorVersion,MinorVersion,Length,ListItemAllFields&#fileUrl={url_encoded_file_path}
Is there anyway to get logged in user while using REST API?
When I use this REST API call, Id returned is the user corresponding to Bearer accesstoken.
https://{site_url}/_api/Web/CurrentUser?$select=Id
When moving a file to another folder, the metadata including author/editor is remained the same one, what changed is only the location. This is by designed.
If we want to know the user who performed this operation, we could check the version events of the file as it will immediately prompt an modification event when moving a file.
FileVersionEvent
Rest API endpoint:
_api/Web/GetFileByServerRelativePath('filepath')/VersionEvents
Thanks

How to determine via API that a Document was deleted in the web sender?

When I go to the Documents tab in the web sender there are no documents listed, but when I use the Java API to list envelopes:
EnvelopesInformation envelopes = envelopesApi.listStatusChanges(accountId, options);
I get documents when I don't expect any. I then realized that all the documents listed via the API are "deleted" documents in the web GUI, but haven't been able to find how to determine via the API that these documents have been deleted - their status is "Completed".
So two questions come from this:
- Is there any way to empty the trash in the web GUI to permanently delete documents?
- Is there any way via the REST API to determine that an envelope has been deleted?
Q: Is there any way to empty the trash in the web GUI to permanently delete documents?
You can move documents to the deleted folder. DocuSign will later empty that folder automatically in the background.
From Documentation
Deleted documents remain in your Deleted bin for only a short time (less than 24 hours), after which they are removed permanently and cannot be recovered.

Clear connections to SharePoint in Word Document

We are having issues with word connecting to SharePoint to retrieve data even if we've downloaded a document from the site.
Here is how our process is setup
We work with documents and prepare them on the workspace
When done a publishing workflow copies the documents using SPFileCollection.Add(string urlOfFile, byte[] file, bool overwrite), http://msdn.microsoft.com/en-us/library/ms428630.aspx
The issue is when opening documents either directly from the published documents site collection or even if we download them to disk the word goes to the workspace site to fetch data (Word Phone Home).
This issue is related with the post linked below but I want to break the "phone home" behavior.
https://sharepoint.stackexchange.com/questions/19390/what-is-slowing-the-opening-of-office-documents

Google Docs Folder Not Found

We are using Document List API version 3. We use two-legged OAuth and get access using permission obtained through Google Apps Marketplace. We retrieve a list of folders contained in a folder as follows:
https://docs.google.com/feeds/default/private/full/folder:[folder doc id]/contents/-/folder?xoauth_requestor_id=[user name]
We get 9 results. We retain the document ids of these folders. Later on we retrieve each folder using their document id as follows where [user name] is the same as what we used previously:
https://docs.google.com/feeds/default/private/full/[folder doc id]?xoauth_requestor_id=[user name]
We are able to get the document (folder) for 8 of the 9 but for one of them we get ResourceNotFoundException no matter when we try and no matter if we retry. We know that the folder still exists and the specified user has access to it.
This is similar in nature to the issue that someone else reported recently in:
Document not found
Is this likely to be a google bug? Any suggestions of how to resolve it other than moving to Google Drive API?
Regards,
LT
How long are you holding onto those document IDs (or really, the contentSrc URL)? I've found that those things can expire after a few hours so you should not cache them for any length of time.

Resources