Skip to content

Bug report: Adding File to SharePoint fails with status code 400, file uploads #1936

@pmatthews05

Description

@pmatthews05

Description

Receive a 400 status code error when uploading a file to SharePoint Online using m365

Steps to reproduce

Using Version 3.2.0
I am logged into m365 as myself who is a Site Collection Administrator on the site.

Using Powershell with the following command.

m365 spo file add --webUrl "https://[tenant].sharepoint.com/sites/Demo" --folder 'Shared Documents' --path 'c:\temp\filetoupload.csv'

I always get a response

node.exe : Error: Request failed with status code 400
At C:\Program Files\nodejs\m365.ps1:12 char:3
+   & "$basedir/node$exe"  "$basedir/node_modules/@pnp/cli-microsoft365 ...
+   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (Error: Request ...status code 400:String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError

The file does appear on the site.

If I use my own Azure AD Identity with certificate, which has the following permissions (incase I have them wrong):

Microsoft Graph:

  • Group.Read.All
  • Sites.Manage.All
    SharePoint:
  • Sites.FullControl.All

I also get 400 exception.

I have tried this in PowerShell, PowerShell Core and Bash and get the same response each time.

Expected result

No error message.

Actual result

node.exe : Error: Request failed with status code 400
At C:\Program Files\nodejs\m365.ps1:12 char:3
+   & "$basedir/node$exe"  "$basedir/node_modules/@pnp/cli-microsoft365 ...
+   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (Error: Request ...status code 400:String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError

m365sharepointfiles
m365bash ong
m365powershell
m365pscore

Environment

M365 CLI v 3.2.0
Windows Bash
PowerShell
PowerShell Core.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions