powershell icon indicating copy to clipboard operation
powershell copied to clipboard

[BUG] - I'm trying to add list items in a simple site.. but keep getting "File not Found" error

Open ollimenzel opened this issue 5 years ago • 6 comments

Category

  • [x] Bug

Describe the bug

I'm trying to use the batch function to add list-items to a custom-list. Here is my script Connect-PnPOnline -Url https://tenant.sharepoint.com -ClientId $clientID -ClientSecret $clientSecret New-PnPList -Title "PnPTestList" -Template GenericList

$list = Get-PnPList -Identity "PnPTestList" $batch = New-PnPBatch

for ($i = 0; $i -lt 100; $i++) { #Add List Item To The Batch - 100 times Add-PnPListItem -List $list -Batch $batch -Values @{"Title" = "Person $i" } }

Execute the batch all at once

Invoke-PnPBatch -Batch $batch -Details

But I'm getting this error image

Doing it without the batch functionality works fine. Tried it on two tenants and two PC's (work / private) but it doesn't work on either set-up.

Steps to reproduce

Just run the code on your Pc

Expected behavior

100 List items should be created

Environment details (development & target environment)

Tried it on my dev and Prod environment

  • SDK version: Pnp 1.5
  • OS: Windows 10
  • SDK used in: Visual Studio Code & Azure Automation
  • Framework: [e.g. .NET Framework v3.x | .NET Core v3.x ]
  • Browser(s): Chromium Edge beta
  • Tooling: VS Code
  • Additional details: The more context you can provide, the easier it is (and therefore quicker) to help.

Additional context

Thanks for your contribution! Sharing is caring.

ollimenzel avatar May 10 '21 12:05 ollimenzel

@ollimenzel - I didn't have any issue running your script (I'm using v1.5.38-nightly) and it created my items. However, not sure if this is a typo, but your -Url https://tenant.sharepoint.com should also include the /sites/<your-site>

Please upgrade or correct your URL, and feedback. Thanks

veronicageek avatar May 10 '21 17:05 veronicageek

@veronicageek Good hunch, I was able to run the script for another SiteCollection (sites/HR), but I wanted to run this on my Root SiteCollection (Intranet Start-Page). This is still not working. Adding an Item without adding to batch first is working fine, also an CSOM only approach is working. Seems to be something about the batching function not working on the root SiteCollection.

ollimenzel avatar May 11 '21 06:05 ollimenzel

@ollimenzel - Yep you're correct, I can reproduce even with 1.5.38-nightly.

FYI - @gautamdsheth / @erwinvanhunen

veronicageek avatar May 11 '21 07:05 veronicageek

This issue is stale because it has been open 14 days with no activity. Remove stale label or comment or this will be closed in 5 days

github-actions[bot] avatar Jun 06 '21 03:06 github-actions[bot]

This has been fixed. Can you give try with the latest PnP PowerShell and check ? If it is fixed for you, can you please close the issue ?

gautamdsheth avatar Jun 08 '21 15:06 gautamdsheth

Closing it as it has been fixed in the latest version. Please reopen if it still exists.

gautamdsheth avatar Jun 15 '21 09:06 gautamdsheth