Account Options

  1. Sign in
The old Google Groups will be going away soon.
Switch to the new Google Groups.
Google Groups Home
« Groups Home
Problems adding a new contact with Python
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  3 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Greg Broiles  
View profile  
 More options Feb 11, 5:31 am
From: Greg Broiles <gbroi...@gmail.com>
Date: Sat, 11 Feb 2012 02:31:23 -0800 (PST)
Local: Sat, Feb 11 2012 5:31 am
Subject: Problems adding a new contact with Python

Here's some example code:

import atom
import gdata.contacts
import gdata.contacts.service
import gdata.contacts.data
import gdata.data

gd_client = gdata.contacts.service.ContactsService()
gd_client.email = 'MYEMAIL'
gd_client.password = 'MYPASSWORD'
gd_client.source = 'test'
gd_client.ProgrammaticLogin()

name="Test Person"
primary_email="testerd...@example.com"

new_contact = gdata.contacts.ContactEntry(title=atom.Title(text=name))
new_contact.email.append(gdata.contacts.Email(address=primary_email,
primary='true', rel=gdata.contacts.REL_WORK))
new_contact.phone_number.append(gdata.contacts.PhoneNumber("650-555-5555",
primary='true'))
new_contact.structured_postal_address.append(gdata.data.StructuredPostalAdd ress(rel=gdata.data.WORK_REL,
primary='true',
    street=gdata.data.Street(text='1600 Amphitheatre Pkwy'),
    city=gdata.data.City(text='Mountain View'),
    region=gdata.data.Region(text='CA'),
    postcode=gdata.data.Postcode(text='94043'),
    country=gdata.data.Country(text='United States')))

contact_entry = gd_client.CreateContact(new_contact)

--

and this is the error it gives me:

C:\Python27\python.exe C:/Users/gbroiles/Projects/google-contacts/c4.py
Traceback (most recent call last):
  File "C:/Users/gbroiles/Projects/google-contacts/c4.py", line 26, in
<module>
    contact_entry = gd_client.CreateContact(new_contact)
  File "C:\Python27\lib\site-packages\gdata\contacts\service.py", line 132,
in CreateContact
    converter=gdata.contacts.ContactEntryFromString)
  File "C:\Python27\lib\site-packages\gdata\service.py", line 1236, in Post
    media_source=media_source, converter=converter)
  File "C:\Python27\lib\site-packages\gdata\service.py", line 1322, in
PostOrPut
    headers=extra_headers, url_params=url_params)
  File "C:\Python27\lib\site-packages\atom\__init__.py", line 93, in
optional_warn_function
    return f(*args, **kwargs)
  File "C:\Python27\lib\site-packages\atom\service.py", line 176, in request
    content_length = CalculateDataLength(data)
  File "C:\Python27\lib\site-packages\atom\service.py", line 736, in
CalculateDataLength
    return len(str(data))
  File "C:\Python27\lib\site-packages\atom\__init__.py", line 377, in
__str__
    return self.ToString()
  File "C:\Python27\lib\site-packages\atom\__init__.py", line 374, in
ToString
    return ElementTree.tostring(self._ToElementTree(),
encoding=string_encoding)
  File "C:\Python27\lib\site-packages\atom\__init__.py", line 369, in
_ToElementTree
    self._AddMembersToElementTree(new_tree)
  File "C:\Python27\lib\site-packages\atom\__init__.py", line 329, in
_AddMembersToElementTree
    instance._BecomeChildElement(tree)
AttributeError: 'StructuredPostalAddress' object has no attribute
'_BecomeChildElement'

--

the problem seems to be in the StructuredPostalAddress part, but I can't
seem to figure out what it doesn't like. The example runs fine if I comment
out the address lines - but I would like to store addresses for my
contacts, surprisingly enough.

Any ideas?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Greg Broiles  
View profile  
 More options Feb 11, 5:34 am
From: Greg Broiles <gbroi...@gmail.com>
Date: Sat, 11 Feb 2012 02:34:54 -0800 (PST)
Local: Sat, Feb 11 2012 5:34 am
Subject: Re: Problems adding a new contact with Python

the phone number line should be

new_contact.phone_number.append(gdata.contacts.PhoneNumber(text="650-555-55 55",
primary='true', rel=gdata.contacts.REL_WORK))


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Alain Vongsouvanh  
View profile  
 More options Feb 23, 6:05 pm
From: Alain Vongsouvanh <ala...@google.com>
Date: Thu, 23 Feb 2012 15:05:11 -0800
Local: Thurs, Feb 23 2012 6:05 pm
Subject: Re: [Contacts API] Re: Problems adding a new contact with Python

Hello,

Creating contacts with the Python client library is documented here:

http://code.google.com/apis/contacts/docs/3.0/developers_guide.html#C...

Best,
Alain

--
Alain Vongsouvanh | Developer Programs Engineer

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »