Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • djamel 4 posts 74 karma points
    Jan 22, 2022 @ 21:11
    djamel
    0

    Delete a content programatically

    Hello,

    We are using Umbraco 8 and I'm trying to delete an IPublishedContent programatically:

    IContent content = _contentService.GetById(contentId);
     if (content!=null)
     {
         _OperationResult opRes = _contentService.Delete(content);
           res = opRes.Success;
    }
    

    Even if the document gets deleted, the Delete method though throws an exception of type System.Exception {System.InvalidOperationException} with message "Duplicate attribute."

    Using _contentService.MoveToRecycleBin(content) works fine!

    Anyone encountered this issue?

    Your help is appreciated!

  • Dennis 75 posts 398 karma points MVP 2x
    Jan 24, 2022 @ 13:23
    Dennis
    0

    Hi djamel,

    Though I haven't encountered this exact error, it may be worth investigating if you have any events subscribed to the content deleted event or the content deleting event. Perhaps one of your subscribers is throwing the exception.

  • djamel 4 posts 74 karma points
    Jan 24, 2022 @ 16:16
    djamel
    0

    Hi Denis, Thanks for the answer but no there is no event listner.

    I noticed also when I delete en item in the backoffice it works well it sends it to the Recycle bin. But when I try to delete it from the Recycle bin I get the same error enter image description here

  • Dennis 75 posts 398 karma points MVP 2x
    Jan 24, 2022 @ 17:46
    Dennis
    0

    Hi djamel,

    That screenshot suggests that there is something wrong with the uSync content edition ContentSerializerBase class. Would it be possible for you to update to the latest compatible version of uSync and uSync content edition?

    You could also try deleting the uSync folder on your machine and perform a fresh export and try again, perhaps your uSync configurations have gone corrupt somehow.

  • djamel 4 posts 74 karma points
    Feb 01, 2022 @ 01:41
    djamel
    0

    Hi Denis, Did not try it yet, but will let you know asap. Thank you!

Please Sign in or register to post replies

Write your reply to:

Draft