python-3.xstringhttpexceptioncaldav

How can I delete an event with CalDAV


I want to delete an Event of my Nextcloud calendar using CalDAV. But when I try to delete an object, I get an error.

This is my code:

import caldav

client = caldav.DAVClient(url='https://ppp.woelkli.com/remote.php/dav', username='XXXXXXXX@gmail.com', password='Xxxxxxxx')
principal = client.Principal()
calendar = principal.calendars()[0]
event = calendar.events()[0]
caldav.Event(client=client, url=str(event), parent = calendar).delete()

And in the last line I get the following error: enter image description here


Solution

  • I believe the correct code is

    import caldav
    
    client = caldav.DAVClient(url='https://ppp.woelkli.com/remote.php/dav', username='XXXXXXXX@gmail.com', password='Xxxxxxxx')
    principal = client.principal()
    calendar = principal.calendars()[0]
    event = calendar.events()[0]
    event.delete()