Skip to content

CSOM has no way to create a file in a library with required metadata without filling ii tin as the UI does. #10819

@marcus905

Description

@marcus905

Target SharePoint environment

SharePoint Online

What SharePoint development model, framework, SDK or API is this about?

SharePoint CSOM

Developer environment

Windows

What browser(s) / client(s) have you tested

  • 💥 Internet Explorer
  • 💥 Microsoft Edge
  • 💥 Google Chrome
  • 💥 FireFox
  • 💥 Safari
  • mobile (iOS/iPadOS)
  • mobile (Android)
  • not applicable
  • other (enter in the "Additional environment details" area below)

Additional environment details

Issue is there in CSOM 16.1.27011.12008, but the same applies to current Power Automate actions.

Describe the bug / error

There is no way to create a file on a library (even leaving it checked out) without filling in the properties at the same time in a way that matches the UI (both modern/classic). The upload without properties will always fail with a "List data validation failed." error.

Steps to reproduce

execute something like this on a library with required metadata and no defaults:

using (MemoryStream contentStream = new())
{
    // Add an empty file.

    uploadFolder = destinationClientContext.Web.GetFolderByServerRelativeUrl(Path.Combine(site.AbsoluteUri,uploadFolderServerRelativeURL));
    destinationClientContext.Load(uploadFolder, f => f.ServerRelativeUrl);
    await destinationClientContext.ExecuteQueryAsync();

    FileCreationInformation emptyFci = new()
    {
        ContentStream = contentStream,
        Url = destinationFileName,
        Overwrite = true
    };

    uploadFile = uploadFolder.Files.Add(emptyFci);

    // push content in chunks... doesn't matter.

    await destinationClientContext.ExecuteQueryAsync();
}

Expected behavior

The file should be uploaded but be checked out -- OR -- there should be a switch in the FileCreationInformation like CheckRequiredFields (as SaveBinary). The same should apply to the Power Automate actions.

Metadata

Metadata

Assignees

Labels

Needs: Author FeedbackAwaiting response from the original poster of the issue. Marked as stale if no activity for 7 days.area:csom/rest/apiCategory: SharePoint Client Side Object Model SDK / REST APIsharepoint-developer-supportsharepoint-developer-supporttype:bug-suspectedSuspected bug (not working as designed/expected). See “type:bug-confirmed” for confirmed bugs.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions