0

Ok, I'm trying to do very simple queries against the Google CardDAV interface. I have a valid OAuth key, I have a valid email address. Using curl, attempting this:

curl --request REPORT  \
     --header "Content-Type: text/xml" \
     --header "Depth: 1" \
     --header "Authorization: Bearer <OAuth Key Here>" \
     --data-ascii "<?xml version=\"1.0\" encoding=\"utf-8\"?> \
                  <D:addressbook-query xmlns:card="urn:ietf:params:xml:ns:carddav"
                     xmlns:cs="http://calendarserver.org/ns/" xmlns:D="DAV:"
                     xmlns:ical="http://apple.com/ns/ical/"> \
                    <card:allprop/> \
                  </D:addressbook-query>" \
https://www.googleapis.com/carddav/v1/principals/<Email Address Here>/lists/default

I have validated the XML, but the response I'm getting from google is:

<?xml version="1.0" encoding="UTF-8"?>
<d:error xmlns:d="DAV:"/>

It would be helpful if I knew what was in error. Any suggestions?

Andy Wallace
  • 609
  • 8
  • 26
  • Yes, what is supposed to be? Did you mean ? Also, you do an addressbook-query but don't actually specify a filter? And why do you set namespace prefixes of namespaces you don't actually use? – hnh Nov 26 '14 at 23:21
  • The extra namespaces are from copy and paste, I'm throwing a lot of stuff at the wall as I try to get a handle on this stuff. Thanks for the pointer on the allprop, I'll try that. We're actually going to veer away from CardDAV anyway, because it's not going to handle what we need to do, and move to the Google Contacts API, but all information helps. Thanks again. – Andy Wallace Dec 01 '14 at 16:49

1 Answers1

0

the namespace for the addressbook-query should be card, not DAV and the allprop should be DAV. I also found that Google CardDav requires a filter, but you can include an empty criteria and it will return all elements. See below:

<?xml version="1.0" encoding="utf-8" ?>
<C:addressbook-query xmlns:D="DAV:" xmlns:C="urn:ietf:params:xml:ns:carddav">
<D:allprop>
    <D:getetag />
    <C:address-data content-type="application/vcard+xml" version="4.0"/>
</D:allprop>
<C:filter>
    <C:prop-filter name="FN">
    </C:prop-filter>    
</C:filter>
</C:addressbook-query>
Derek Wade
  • 697
  • 8
  • 11