Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

find_events() stops working w/ OwnCloud 9.x (REPORT Error) #2

Open
ghost opened this issue Feb 10, 2017 · 1 comment
Open

find_events() stops working w/ OwnCloud 9.x (REPORT Error) #2

ghost opened this issue Feb 10, 2017 · 1 comment

Comments

@ghost
Copy link

ghost commented Feb 10, 2017

I've updated to OwnCloud 9.1.4 and faced problems when trying to fetch CalDAV events via the find_events() method. The OwnCloud-Server sends a 400 (Bad Request) response with the following body:

<?xml version="1.0" encoding="utf-8"?>
<d:error xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns">
  <s:sabredav-version>3.0.9</s:sabredav-version>
  <s:exception>Sabre\DAV\Exception\BadRequest</s:exception>
  <s:message>A calendar-query REPORT on a calendar with a Depth: 0 is undefined. Set Depth to 1</s:message>
</d:error>

I fixed this by adding the necessary "Depth" HTTP request header in

lib/twisted-caldav/client.rb, line 67:

 req = Net::HTTP::Report.new(@url, initheader = {'Content-Type'=>'application/xml', 'Depth'=>'1'} )

Maybe you could add this extra header to your code as well - maybe this helps others who run into this problem.

@ghost
Copy link
Author

ghost commented Feb 14, 2017

And one more thing regarding find_events() and OwnCloud 9.x - the event parsing is also not working as expected and needs to be patched.

In client.rb, line 87 the CalDav events are being extracted as plain text

REXML::XPath.each( xml, '//c:calendar-data/', {"c"=>"urn:ietf:params:xml:ns:caldav"} ){|c| result << c.text }

The next line

r = Icalendar.parse(result)

fails to parse the text stored in "result", because a line-break is missing after "END:VCALENDAR".

So it's necessary to manually add a line-break and then it works again:

client.rb, line 87:

        REXML::XPath.each( xml, '//c:calendar-data/', {"c"=>"urn:ietf:params:xml:ns:caldav"} ){|c| result << "#{c.text}\n" }

Hope this helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants