403 CalDAV错误:有效日历对象资源 [英] 403 CalDAV error: valid-calendar-object-resource

查看:191
本文介绍了403 CalDAV错误:有效日历对象资源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在iCloud日历中创建一个新活动。我收到 valid-calendar-object-resource 错误,根据规范说我的 PUT 请求不符合规范中的第4.1节

I'm attempting to create a new event in an iCloud calendar. I'm getting a valid-calendar-object-resource error, which according to the spec says my PUT request doesn't meet Section 4.1 in the spec.

但是,这是请求的正文,据我所知,确实满足4.1中的所有要求:

However, this is the body of the request, which, as far as I can tell, does meet all the requirements in 4.1:

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

该iCalendar数据是否有问题,或者错误是否在其他地方?

Is there anything wrong with that iCalendar data, or would the error be elsewhere?

请求选项

对节点使用请求

{"auth":{"user":"feifan@me.com","pass":"XXX"},"headers":{"Content-Type":"text/calendar","Depth":"1","User-Agent":"DAVKit/4.0.1 (730); CalendarStore/4.0.1 (973); iCal/4.0.1 (1374); Mac OS X/10.6.2 (10C540)"},"method":"PUT","url":"https://p05-caldav.icloud.com/267369040/calendars/home/","body":"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"}

响应:

<?xml version='1.0' encoding='UTF-8'?><error xmlns='DAV:'><valid-calendar-object-resource xmlns='urn:ietf:params:xml:ns:caldav'/></error>

CURL尝试

curl -v -X PUT -H "Content-Type:text/calendar" -H "User-Agent:DAVKit/4.0.1 (730); CalendarStore/4.0.1 (973); iCal/4.0.1 (1374); Mac OS X/10.6.2 (10C540)" -u "feifan@me.com:XXXXX" --data-binary @- https://p05-caldav.icloud.com/267369040/calendars/home/  <<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

CURL详细响应

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'
> PUT /267369040/calendars/home/ HTTP/1.1
> Host: p05-caldav.icloud.com
> Authorization: Basic XXXXXX=
> Accept: */*
> Content-Type:text/calendar
> User-Agent:DAVKit/4.0.1 (730); CalendarStore/4.0.1 (973); iCal/4.0.1 (1374); Mac OS X/10.6.2 (10C540)
> Content-Length: 273
>
* upload completely sent off: 273 out of 273 bytes
< HTTP/1.1 403 Forbidden
< Content-Type: text/xml
< DAV: 1, access-control, calendar-access, calendar-schedule, calendar-auto-schedule, calendar-managed-attachments, calendarserver-sharing, calendarserver-subscribed, calendarserver-home-sync
< Server: iCloudCalendarServer 15G33
< Date: Thu, 14 Jan 2016 15:40:18 GMT
< X-Responding-Server: st11p02me-caldav042 11 a63660a6f7d1a25b5a7ed66dab0da843
< X-Transaction-Id: b22d6d88-e7dd-4766-a92a-b42dca0775f3
< Content-Length: 137
< Strict-Transport-Security: max-age=31536000; includeSubDomains
< Via: icloudedge:sv05p00ic-ztde010832:8401:15G126:San Jose
< X-Apple-Request-UUID: b22d6d88-e7dd-4766-a92a-b42dca0775f3
< Access-Control-Expose-Headers: X-Apple-Request-UUID
< Access-Control-Expose-Headers: Via
< x-apple-edge-info: AAAAAQA7aHR0cHM6Ly9wMDItY2FsZGF2LmljbG91ZC5jb206NDQzLzI2NzM2OTA0MC9jYWxlbmRhcnMvaG9tZS8ACXVuZGVmaW5lZAAA
<
* Connection #0 to host p05-caldav.icloud.com left intact
<?xml version='1.0' encoding='UTF-8'?><error xmlns='DAV:'><valid-calendar-object-resource xmlns='urn:ietf:params:xml:ns:caldav'/></error>


推荐答案

iCalendar数据本身似乎很好,因为它为我工作。我可以将您的活动上传到我的帐户中,并显示在我的日历中。

The iCalendar data itself seems to be fine, since it works for me. I can upload your event to my account and it appears in my calendar.

请确保


  1. 您在 PUT 事件中指定正确的内容类型文本/日历

  2. 您正在编写的集合实际上支持事件。 iCloud对 VEVENT VTODO 使用单独的集合。虽然,如果我尝试写入仅 VTODO 的集合,则可以重定向到主日历集合,而不是错误。

  1. you specify the correct content-type text/calendar when you PUT the event.
  2. the collection that you're writing to actually supports events. iCloud uses separate collections for VEVENTs and VTODOs. Although, if I try to write to a VTODO-only collection, I get a redirect to the main calendar collection instead of an error.



更新



对您的请求还有两个评论。

update

Two more comments on your request.


  1. 发送带有 PUT 请求的 Depth 标头没有任何意义,并且您应该将其删除,但不会导致错误

  2. 您的 PUT 被定向到日历收集URL,而不是集合的成员URL。大多数服务器会立即拒绝该请求。 iCloud似乎接受并创建了事件。但是看来您只能执行一次。后续对日历收集URL的 PUT 请求被拒绝,并出现 412 Precondition Failed 错误(即使UID不同)。直到事件被删除。

  1. sending a Depth header with a PUT request doesn't make any sense and you should remove it, but it won't cause the error
  2. your PUT is directed to the calendar collection URL, not to a member URL of the collection. Most servers would just reject that right away. iCloud seem to accept that and creates the event anyway. But it looks like you can do that only once. Subsequent PUT requests to the calendar collection URL are rejected with a 412 Precondition Failed error (even if the UID is different) until the event is deleted.

您应该附加一个随机文件名。最好使用包含事件的 UID 的东西,例如< UID> .ics ,但是您应该请考虑先删除 @ ,因为在何时或是否对其进行编码方面存在很多困惑。

You should append a random filename. It's good practice to use something that contains the UID of the event like <UID>.ics, but you should consider to remove the @ first, since there is a lot of confusion about when or whether to encode it or not.

但是,我仍然无法使用此数据重现该问题。

好,现在我可以复制它了。如上所述,问题是您没有在URL中指定文件名。

Ok, now I'm able to reproduce it. As noted above the problem is that you don't specify a file name in your URL.

再次尝试执行curl请求,如下所示:

Try the curl request again like this:

curl -v -X PUT -H "Content-Type:text/calendar" -u "feifan@me.com:XXXXX" --data-binary @- https://p05-caldav.icloud.com/267369040/calendars/home/3xq8the-calendar-api.herokuapp.com.ics  <<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

请注意网址末尾的文件名。就像@hnh提到的那样,请使用您自己的用户代理。不要让您的客户假装成别人。

Note the file name at the end of the url. Also as @hnh has mentioned, use your own user agent. Don't let your client pretend to be someone else.

这篇关于403 CalDAV错误:有效日历对象资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆