Recently while working on uploading large files to SharePoint online document library using PowerShell in SharePoint online, I got the below error which says: Method invocation failed because [Microsoft.SharePoint.Client.File] does not contain a method named ‘StartUpload’
Method invocation failed because [Microsoft.SharePoint.Client.File] does not contain a method named StartUpload
Below is the code we can write using Visual Studio Code or Windows PowerShell ISE.
$ContentStream = New-Object System.IO.MemoryStream
# Add an empty file.
$fileInfo = New-Object Microsoft.SharePoint.Client.FileCreationInformation
$fileInfo.ContentStream = $ContentStream
$fileInfo.Url = $UniqueFileName
$fileInfo.Overwrite = $true
$Upload = $Docs.RootFolder.Files.Add($fileInfo)
$ctx.Load($Upload)
# Start upload by uploading the first slice.
$s = [System.IO.MemoryStream]::new($buffer)
# Call the start upload method on the first slice.
$BytesUploaded = $Upload.StartUpload($UploadId, $s)
$ctx.ExecuteQuery()
The error was coming in the below line:
$BytesUploaded = $Upload.StartUpload($UploadId, $s)
Read some SharePoint errors and solutions:
- PowerShell SharePoint Online: The remote server returned an error: (403) Forbidden
- Uncaught ReferenceError: web is not defined Error in SharePoint Online JSOM
- Column does not exist. it may have been deleted by another user error in SharePoint Online
- Error occurred in deployment step ‘Install SharePoint Add-in’: The remote server returned an error: (503) Server unavailable
- http error 400. the size of the request headers is too long. sharepoint online
- Unable to connect SharePoint site. The Operation could not be completed error in InfoPath 2013
- New-SPWebApplication ApplicationPoolAccount is not found error while creating SharePoint 2016 web application using PowerShell
- Server error: The version of Microsoft SharePoint Foundation running on the server is more recent than the version of SharePoint Designer you are using
- Request timed out error while Creating New Web Application through SharePoint 2016 Central Administration
- Error occurred in deployment step ‘Install SharePoint Add-in’: An instance of this App already exists at the specified location.
- A SharePoint list that contains data required for this form to function correctly cannot be found InfoPath SharePoint online error
- Microsoft .net framework 4.6 installation error SharePoint 2016
Here I was using the 15 versions of Microsoft.SharePoint.Client.dll and Microsoft.SharePoint.Client.Runtime.dll. Here you need to use the 16 versions of both the dlls. Once I replaced with updated 16 versions of client dlls, it worked fine.
Hello Everyone!! I am Bhawana a SharePoint MVP and having about 10+ years of SharePoint experience as well as in .Net technologies. I have worked in all the versions of SharePoint from wss to Office 365. I have good exposure in Customization and Migration using Nintex, Metalogix tools. Now exploring more in SharePoint 2016 🙂 Hope here I can contribute and share my knowledge to the fullest. As I believe “There is no wealth like knowledge and no poverty like ignorance”