0

I have below code , but it gives mentioned error on ExecuteQuery() after item.DeleteObject().


Site collSite1 = _ctx1.Site;
RecycleBinItemCollection collRBI1 = collSite1.RecycleBin;
_ctx1.Load(collRBI1);
_ctx1.ExecuteQuery();

RecycleBinItem item = collRBI1.SingleOrDefault(coll => coll.Id.ToString() == Id); //Here Id will have some value like "9aff6090-aecc-4342-a3a6-c2ecd957daee"

item.DeleteObject();
_ctx1.ExecuteQuery();


I also tried by putting this in web.config as per some solution in searching but failed.

add key="aspnet:MaxHttpCollectionKeys" value="20000"

Any idea what this issue is about?

2

1 Answer 1

0

There is no need to load RecycleBinItem collection, use RecycleBinItemCollection.GetById method to get Recycle Bin item by the specified identifier from the collection.

The following example demonstrates how to find RecycleBinItem by identifier and delete it:

var recycleBinItemId = new Guid("recycle bin item guid");
var recycleBinItem = ctx.Site.RecycleBin.GetById(recycleBinItemId);
recycleBinItem.DeleteObject();
ctx.ExecuteQuery();

Key points:

  • Allows to delete RecycleBinItem using a single request to a server
1
  • Thanks Vadim for reply, I applied your given code but still it shows the same Error on ctx.ExecuteQuery().
    – Kb15
    Oct 2, 2014 at 11:48

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.