geier / pycarddav

DEPRECATED - use vdirsyncer & khard -- easy to use CLI CardDAV client
http://lostpackets.de/pycarddav
MIT License
98 stars 35 forks source link

requests.exceptions.HTTPError: 400 Client Error #44

Closed chrisisbd closed 11 years ago

chrisisbd commented 11 years ago

I've managed to break my installation of pycarddav :-(

I've copied what I thought were my original pycarddav files back into the right places but I'm getting the following error:-

chris$ pycardsyncer INFO:urllib3.connectionpool:Starting new HTTP connection (1): localhost INFO:urllib3.connectionpool:Starting new HTTP connection (2): localhost INFO:urllib3.connectionpool:Starting new HTTP connection (1): localhost INFO:urllib3.connectionpool:Starting new HTTP connection (1): localhost INFO:urllib3.connectionpool:Starting new HTTP connection (1): localhost INFO:urllib3.connectionpool:Starting new HTTP connection (1): localhost INFO:urllib3.connectionpool:Starting new HTTP connection (1): localhost CRITICAL:root:While syncing account "main" an error occured: 400 Client Error

geier commented 11 years ago

please use --debug and post the stack trace again

chrisisbd commented 11 years ago

I've just (an hour or so ago) found the problem. The CardDAV server I'm using is owncloud and that uses the SabreDAV libraries for the server code. The '400 Client Error' actually means 'Every vcard must have an UID.'. The owncloud code loses the text from the exception which is why it took me so long to find the error.

I have just added a couple of lines to model.py so that every vCard from pycard-import will have a UID. I'm about to try it out.

chrisisbd commented 11 years ago

... and it works now! :-)

I've made a very crude addition for the moment so that in model.py there is now:-

def vcard_from_email(display_name, email): fname, lname = get_names(display_name) vcard = vobject.vCard() vcard.add('n') vcard.n.value = vobject.vcard.Name(family=lname, given=fname) vcard.add('fn') vcard.fn.value = display_name vcard.add('email') vcard.email.value = email vcard.email.type_param = 'INTERNET' vcard.add('uid') vcard.uid.value = get_random_href() return vcard_from_vobject(vcard)

I simply copied get_random_href() from carddav.py.

I suspect that other CardDAV servers may have the same requirement so adding a UID may be a good idea. It doesn't need to be such a long random number, owncloud itself just uses an 8 digit number (a third of what get_random_href() produces).

geier commented 11 years ago

thanks for the info, I'll but that on the todo list

chrisisbd commented 11 years ago

OK. Sorry I got a bit confused because I thought I had changed something in my copy of pycarddav that had stopped it working, hence my question about which version I should be using.

Thanks for all the help.

If you want any testing/debugging done I'm very happy to help.

geier commented 11 years ago

no problem, happy to help