title: 403 CalDAV error: valid-calendar-object-resource
body: <p>I'm attempting to create a new event in an iCloud calendar. I'm getting a <code>valid-calendar-object-resource</code> error, which according to the <a href="https://www.rfc-editor.org/rfc/rfc4791#section-5.3.2.1" rel="nofollow noreferrer">spec</a> says my <code>PUT</code> request doesn't meet <a href="https://www.rfc-editor.org/rfc/rfc4791#section-4.1" rel="nofollow noreferrer">Section 4.1 in the spec</a>.</p>
  <p>However, this is the body of the request, which, as far as I can tell, does meet all the requirements in 4.1:</p>
  <pre><code>BEGIN:VCALENDAR
  VERSION:2.0
  PRODID:-//sebbo.net//ical-generator//EN
  BEGIN:VEVENT
  UID:3xq8@the-calendar-api.herokuapp.com
  SEQUENCE:0
  DTSTAMP:20160113T023753Z
  DTSTART:20160113T033753Z
  DTEND:20160113T043753Z
  SUMMARY:Example Event
  DESCRIPTION:It works
  END:VEVENT
  END:VCALENDAR
  </code></pre>
  <p>Is there anything wrong with that iCalendar data, or would the error be elsewhere?</p>
  <p><strong>Request options</strong></p>
  <p>Using <a href="https://github.com/request/request" rel="nofollow noreferrer">request</a> for Node</p>
  <pre><code>{&quot;auth&quot;:{&quot;user&quot;:&quot;feifan@me.com&quot;,&quot;pass&quot;:&quot;XXX&quot;},&quot;headers&quot;:{&quot;Content-Type&quot;:&quot;text/calendar&quot;,&quot;Depth&quot;:&quot;1&quot;,&quot;User-Agent&quot;:&quot;DAVKit/4.0.1 (730); CalendarStore/4.0.1 (973); iCal/4.0.1 (1374); Mac OS X/10.6.2 (10C540)&quot;},&quot;method&quot;:&quot;PUT&quot;,&quot;url&quot;:&quot;https://p05-caldav.icloud.com/267369040/calendars/home/&quot;,&quot;body&quot;:&quot;BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:-//sebbo.net//ical-generator//EN\r\nBEGIN:VEVENT\r\nUID:cc2x@the-calendar-api.herokuapp.com\r\nSEQUENCE:0\r\nDTSTAMP:20160114T061844Z\r\nDTSTART:20160114T071844Z\r\nDTEND:20160114T081844Z\r\nSUMMARY:Example Event\r\nDESCRIPTION:It works\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n&quot;}
  </code></pre>
  <p><strong>Response:</strong></p>
  <pre><code>&lt;?xml version='1.0' encoding='UTF-8'?&gt;&lt;error xmlns='DAV:'&gt;&lt;valid-calendar-object-resource xmlns='urn:ietf:params:xml:ns:caldav'/&gt;&lt;/error&gt;
  </code></pre>
  <p><strong>CURL Attempt</strong></p>
  <pre><code>curl -v -X PUT -H &quot;Content-Type:text/calendar&quot; -H &quot;User-Agent:DAVKit/4.0.1 (730); CalendarStore/4.0.1 (973); iCal/4.0.1 (1374); Mac OS X/10.6.2 (10C540)&quot; -u &quot;feifan@me.com:XXXXX&quot; --data-binary @- https://p05-caldav.icloud.com/267369040/calendars/home/  &lt;&lt;EOF
  BEGIN:VCALENDAR
  VERSION:2.0
  PRODID:-//sebbo.net//ical-generator//EN
  BEGIN:VEVENT
  UID:3xq8@the-calendar-api.herokuapp.com
  SEQUENCE:0
  DTSTAMP:20160113T023753Z
  DTSTART:20160113T033753Z
  DTEND:20160113T043753Z
  SUMMARY:Example Event
  DESCRIPTION:It works
  END:VEVENT
  END:VCALENDAR
  EOF
  </code></pre>
  <p><strong>CURL verbose response</strong></p>
  <pre><code>Trying 17.248.128.211...
  * Connected to p05-caldav.icloud.com (17.248.128.211) port 443 (#0)
  * TLS 1.2 connection using TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
  * Server certificate: *.icloud.com
  * Server certificate: Apple IST CA 2 - G1
  * Server certificate: GeoTrust Global CA
  * Server auth using Basic with user 'feifan@me.com'
  &gt; PUT /267369040/calendars/home/ HTTP/1.1
  &gt; Host: p05-caldav.icloud.com
  &gt; Authorization: Basic XXXXXX=
  &gt; Accept: */*
  &gt; Content-Type:text/calendar
  &gt; User-Agent:DAVKit/4.0.1 (730); CalendarStore/4.0.1 (973); iCal/4.0.1 (1374); Mac OS X/10.6.2 (10C540)
  &gt; Content-Length: 273
  &gt;
  * upload completely sent off: 273 out of 273 bytes
  &lt; HTTP/1.1 403 Forbidden
  &lt; Content-Type: text/xml
  &lt; DAV: 1, access-control, calendar-access, calendar-schedule, calendar-auto-schedule, calendar-managed-attachments, calendarserver-sharing, calendarserver-subscribed, calendarserver-home-sync
  &lt; Server: iCloudCalendarServer 15G33
  &lt; Date: Thu, 14 Jan 2016 15:40:18 GMT
  &lt; X-Responding-Server: st11p02me-caldav042 11 a63660a6f7d1a25b5a7ed66dab0da843
  &lt; X-Transaction-Id: b22d6d88-e7dd-4766-a92a-b42dca0775f3
  &lt; Content-Length: 137
  &lt; Strict-Transport-Security: max-age=31536000; includeSubDomains
  &lt; Via: icloudedge:sv05p00ic-ztde010832:8401:15G126:San Jose
  &lt; X-Apple-Request-UUID: b22d6d88-e7dd-4766-a92a-b42dca0775f3
  &lt; Access-Control-Expose-Headers: X-Apple-Request-UUID
  &lt; Access-Control-Expose-Headers: Via
  &lt; x-apple-edge-info: AAAAAQA7aHR0cHM6Ly9wMDItY2FsZGF2LmljbG91ZC5jb206NDQzLzI2NzM2OTA0MC9jYWxlbmRhcnMvaG9tZS8ACXVuZGVmaW5lZAAA
  &lt;
  * Connection #0 to host p05-caldav.icloud.com left intact
  &lt;?xml version='1.0' encoding='UTF-8'?&gt;&lt;error xmlns='DAV:'&gt;&lt;valid-calendar-object-resource xmlns='urn:ietf:params:xml:ns:caldav'/&gt;&lt;/error&gt;
  </code></pre>