Creating New Event to iCloud Apple Calendar always Results 400 Bad Request

倾然丶 夕夏残阳落幕 提交于 2019-12-18 09:34:14

问题


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:

  1. Header: If-None-Match: *
  2. Method: PUT
  3. Uri destination: https://p46-caldav.icloud.com/[USER_ID]/calendars/work/dfsfsdfsfsfsfsdfsdfsdf.ics
  4. Content type: text/calendar
  5. 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);
  6. 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!