We are developing an API to be called by external application.
To have unqiue document ID across Site Collection we have enabled “Document ID service”
Using CSOM we have been able to implement
- Upload File
- Download file by passing ‘Document ID’
However struggling to file a way to delete document using ‘Document ID’. That is the caller will only be passing the unique Document ID and we have to delete it. Googling around getting SOM codeDelete document from document Library Using Document ID
As we are implementing it for SharePoint 2016 and donot want to use anything which will run only the Server, we are looking for CSOM / REST implementation.
Kindly let know if any further details required.
For CSOM I would would a CAML query to get the item. The Document ID column is stored on the item as “_dlc_DocId”. Once you get the item, you can delete it normally.
A CAMLQuery could be something like this (untested) .
<code><span class="str"><View><Query><Where><Eq></span><span class="str"><FieldRef Name='_dlc_DocId'/><Value Type='Text'>DOCID-01-23</Value></span><span class="str"></Eq></Where></Query></View></span></code>
For REST you can use the same column to filter on. However, in both scenarios you’ll need to know the library name or location.
<code><span class="str">$filter=OData__dlc_DocId eq 'DOCID-01-23'</span></code>
If you don’t know the library name, you can use the SharePoint Search REST API to query for the items with that DocumentID.