I'm trying to upload a file into a SharePoint document library using the C# CSOM library. The document library I'm uploading into has information rights management settings enforced.

When I try to upload a file (either a PDF document or a Word document - both without any sort of protection applied), I receive the following error message:

This library does not accept files of the given type. You must either upload a new, unprotected file that supports rights management or re-upload a document that was previously downloaded from this library

I was under the impression that both Word documents and PDF documents are supported by rights management? I've tried manually uploading both files through the SharePoint UI (to rule out a problem with the files I'm using) and they get added into the document library without any issues.

The code I'm using to upload the file is shown below (it's pretty much taken from the sample at https://github.com/OfficeDev/PnP/blob/master/Samples/Core.LargeFileUpload/Core.LargeFileUpload/FileUploadService.cs):

using (var ctx = GetContext(server))
    Web web = ctx.Web;
    ctx.Load(web.Lists, lists => lists.Include(list => list.Title, list => list.RootFolder));

    if (!ListExists(ctx, web, listName))
        throw new InvalidOperationException($"The list '{listName}' does not exist!");

    FileCreationInformation newFile = new FileCreationInformation
        ContentStream = fileStream,
        Url = Path.GetFileName(fileName),
        Overwrite = true

    List docs = web.Lists.GetByTitle(listName);
    Microsoft.SharePoint.Client.File uploadFile = docs.RootFolder.Files.Add(newFile);

    if (fileProperties != null && fileProperties.Any())
        var listItem = uploadFile.ListItemAllFields;

        foreach (var fileProperty in fileProperties)
            listItem[fileProperty.Key] = fileProperty.Value;


    uploadFile.CheckIn("Initial checkin", CheckinType.MajorCheckIn);

Is there a step I'm missing?

1 Answer 1


After some further investigation, it seems that the problem was caused due to the naming of the uploaded file. The file name I used did not have a file extension, which must have some bearing on which IRM protector SharePoint applies to the uploaded file (which seems obvious now in hindsight!).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.