I am trying to use Sardine to query Apple iCloud Calendar. However, it seems to me Sardine is not properly parsing the response.
This is my CalDav time range query:
<?xml version="1.0" encoding="utf-8" ?>
<c:calendar-query xmlns:d="DAV:" xmlns:c="urn:ietf:params:xml:ns:caldav">
<d:prop>
<d:getetag/>
<c:calendar-data/>
</d:prop>
<c:filter>
<c:comp-filter name="VCALENDAR">
<c:comp-filter name="VEVENT">
<c:time-range start="20170501T000000Z" end="20170630T000000Z"/>
</c:comp-filter>
</c:comp-filter>
</c:filter>
</c:calendar-query>
When firing this query using a HTTP client (Insomnia), I get my reply with my 3 test events without any problems. Please note I removed part of the calendar data to make it shorter):
<?xml version='1.0' encoding='UTF-8'?>
<multistatus
xmlns='DAV:'>
<response>
<href>/2003926771/calendars/home/DF4C980C-C189-4DAB-80CE-991A4636593D.ics</href>
<propstat>
<prop>
<getetag>"C=62@U=974e7f83-44fb-4eb2-8386-46012509f5af"</getetag>
<calendar-data
xmlns='urn:ietf:params:xml:ns:caldav'>
<![CDATA[BEGIN:VCALENDAR
VERSION:2.0
BEGIN:VEVENT
UID:DF4C980C-C189-4DAB-80CE-991A4636593D
DTSTART;TZID=Europe/Zurich:20170522T150000
DTEND;TZID=Europe/Zurich:20170522T160000
SUMMARY:Test event
END:VEVENT
END:VCALENDAR
]]>
</calendar-data>
</prop>
<status>HTTP/1.1 200 OK</status>
</propstat>
</response>
<response>
<href>/2003926771/calendars/home/4A9F9785-A8A4-4E61-A600-D5A5C041950E.ics</href>
<propstat>
<prop>
<getetag>"C=115@U=974e7f83-44fb-4eb2-8386-46012509f5af"</getetag>
<calendar-data
xmlns='urn:ietf:params:xml:ns:caldav'>
<![CDATA[BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
BEGIN:VEVENT
UID:4A9F9785-A8A4-4E61-A600-D5A5C041950E
DTSTART;TZID=Europe/Zurich:20170601T120000
DTEND;TZID=Europe/Zurich:20170601T130000
SUMMARY:test event in June
END:VEVENT
END:VCALENDAR
]]>
</calendar-data>
</prop>
<status>HTTP/1.1 200 OK</status>
</propstat>
</response>
<response>
<href>/2003926771/calendars/home/33D1A876-87E6-4165-8AE6-EDD2FA588964.ics</href>
<propstat>
<prop>
<getetag>"C=114@U=974e7f83-44fb-4eb2-8386-46012509f5af"</getetag>
<calendar-data
xmlns='urn:ietf:params:xml:ns:caldav'>
<![CDATA[BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
BEGIN:VEVENT
UID:33D1A876-87E6-4165-8AE6-EDD2FA588964
DTSTART;TZID=Europe/Zurich:20170530T120000
DTEND;TZID=Europe/Zurich:20170530T130000
LAST-MODIFIED:20170530T071831Z
SUMMARY:another test event
END:VEVENT
END:VCALENDAR
]]>
</calendar-data>
</prop>
<status>HTTP/1.1 200 OK</status>
</propstat>
</response>
</multistatus>
However, when I send exactly the same query through a Sardine Report, I am not able to read the calendat-data
content.
In more details, when executing the code below, getAny
returns an empty list. As per my google researches, this should contain a list with xml nodes under prop (with the nodes other than a few pre-defined ones that are stored under different objects under Prop, like etag
).
@Override
public List<VEvent> fromMultistatus(Multistatus multistatus) {
List<VEvent> events = new ArrayList<>(multistatus.getResponse().size());
for (Response response : multistatus.getResponse()) {
for (Propstat propstat : response.getPropstat()) {
System.out.println(propstat.getProp().getAny().get(0).getFirstChild().getTextContent());
}
}
return events;
}
I even debugged the entire multistatus
object, which contains the response. There's no signal of my calendar data.