问题
Currently, I am developing a website which will sync data from Apple Calendar to my app and vice versa.
For fetching data from Apple Calendar to my application, I already can get the .ics
files from iCloud calendar and it works just fine.
However, I have an issue when creating new Event in Apple Calendar. Somehow, every request that I send results 400 Bad Request
.
Here is the detail of the request:
- Header:
If-None-Match: *
- Method:
PUT
- Uri destination:
https://p46-caldav.icloud.com/[USER_ID]/calendars/work/dfsfsdfsfsfsfsdfsdfsdf.ics
- Content type:
text/calendar
- Apple Id and App Specific Password are set using NetworkCredential. This works fine for fetching data from Apple Calendar, so I don't think this is the source of the problem. Here is the snipped code of it:
httpWebRequest.Credentials = new NetworkCredential(username, password);
- For request content, actually I have tried so many things. Here I will just set the one from RFC 4791
BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//Example Corp.//CalDAV Client//EN
BEGIN:VEVENT
UID:20010712T182145Z-123401@example.com
DTSTAMP:20060712T182145Z
DTSTART:20060714T170000Z
DTEND:20060715T040000Z
SUMMARY:Bastille Day Party
END:VEVENT
END:VCALENDAR
Anyone knows what possibly can be wrong?
来源:https://stackoverflow.com/questions/50720196/creating-new-event-to-icloud-apple-calendar-always-results-400-bad-request