File not found when creating a Document Set with CSOM

I had to debug an error which was hard to reproduce from Visual Studio or hard to find a solution for. In this case a Document Set is created through CSOM in SharePoint 2013, triggered by an external application.

The user receives the error “File not found” when creating the document set. Luckily this was SharePoint 2013 on-premises and I could go into the ULS logs to find the details of the CSOM request. There you could find errors like:

“System.IO.FileNotFoundException: The filename, directory name, or volume label syntax is incorrect. (Exception from HRESULT: 0x8007007B)”

and

“DocumentSet Create [libraryname] in [document set title] : throws exception: The filename, directory name, or volume label syntax is incorrect. (Exception from HRESULT: 0x8007007B).”

SharePoint also logs the XML of the CSOM request. There I found something in the Document Set title that shouldn’t be there, a trailing space.

So lesson learned, if you create SharePoint artifacts from an external system, make sure to trim your strings.

1 Comment

  • London Baker says:

    a Document Set is created through CSOM in SharePoint 2013, triggered by an external application.

    I was looking for code to do this with the external application being (Dynamics CRM). I could not find a webservice or REST call to trigger the creation of a Document Set. Can you share the source code that does this? Thanks

Leave a Reply

Your email address will not be published. Required fields are marked *