Retrieving contacts by group?

67 views
Skip to first unread message

Thomas Kristensen

unread,
Oct 22, 2008, 7:44:36 AM10/22/08
to Google Contacts API
Greetings everyone!

I am making a program in C# thats supposed to get all contacts and
groups from Google and stuff it (nicely) into a treeview-control. I
am, however, having a bit of a problem that I was hoping someone could
help me with.

What I want to do is this:
1) Get all groups
2) For each group, get all contacts in that group.

I thought it would be fairly straightforward as there is a "Group"
property on the ContactsQuery which, supposedly, would limit the
feedresult to those contacts in that particular group. But I just
can't get it to work :-(

Here are some snippets of my code:

MyContactService = new ContactsService("My Google Control Panel for
Contacts v. 1.0");
MyContactService.setUserCredentials(m_username, m_password);
MyGroupQuery = new
GroupsQuery(GroupsQuery.CreateGroupsUri("default"));
MyGroupQuery.NumberToRetrieve = 100; // A little large
MyGroupFeed = new MyContactService.Query(MyGroupQuery);

foreach (GroupEntry ge in MyGroupFeed.Entries)
{
MyContactQuery = new
ContactsQuery(ContactsQuery.CreateContactsUri("default"));
MyContactQuery.Group = ge.Id.AbsoluteUri;
MyContactFeed = MyContactService.Query(MyContactQuery);
....
....
}

Its a bit mocked up here, but I hope you get the idea anyways. The
thing is, I get no results back even though I know there are contacts
in whatever group I'm currently working on. I've saved the feed XML
from both queries (using MyContactQuery.Group = "") and in the files,
I can see the ID's for both groups and contacts match. I just can't
seem to make the API filter on the query.

Any help on this would be greatly appreciated as I'm going slightly
nuts here... :-P

Regards,
Thomas Kristensen

Trevor Johns

unread,
Nov 4, 2008, 11:03:09 PM11/4/08
to google-co...@googlegroups.com

Thomas,
An empty feed, assuming the XML is otherwise correct, means that the
server is returning a feed that's different from what's expected by
your code.

My advice is to add some print statements to see whether you're not
not getting any groups, or you're not receiving any contacts.

You also might be able to get some better advice on the .NET client's
discussion group:

http://groups.google.com/group/gdata-dotnet-client-library

--
Trevor Johns

Supergibbs

unread,
Nov 25, 2008, 5:46:59 AM11/25/08
to Google Contacts API
This is a bug in the .NET implementation of the Google Data API. I've
found and fixed the bug but it's not in the latest release. It's been
reported it here:

http://code.google.com/p/google-gdata/issues/detail?id=189

I've included a rebuilt DLL in the above link

-Jesse



On Oct 22, 3:44 am, Thomas Kristensen <vrip...@gmail.com> wrote:
> Greetings everyone!
>
> I am making a program in C# thats supposed to get all contacts andgroupsfrom Google and stuff it (nicely) into a treeview-control. I
> I can see the ID's for bothgroupsand contacts match. I just can't
Reply all
Reply to author
Forward
0 new messages