Hi All,
I am brand new to the Google API's but I am making a simple call to a
domain account using an administrator log in to get all the Shared
Conctacts which I know are 87. The code is below, I can authenticate
just fine but when I send a Get Full
https://www.google.com/m8/feeds/contacts/zabatt.com/full
it returns a proper response with no contacts... The code is below and
the response is at the bottom.
Any ideas?
[code]
String url = "
https://www.google.com/accounts/ClientLogin";
WebRequest request = WebRequest.Create(url);
String accountType = "HOSTED";
String email = "
myadmin...@zabatt.com";
String password = "myadminpassword";
String service = "cp";
String source = "Zabatt-ContactSync-1";
request.Method = "POST";
string postData = String.Format("accountType={0}&Email={1}
&Passwd={2}&service={3}&source={4}", accountType, email, password,
service, source);
byte[] byteaArray = Encoding.UTF8.GetBytes(postData);
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = byteaArray.Length;
Stream dataStream = request.GetRequestStream();
dataStream.Write(byteaArray, 0, byteaArray.Length);
dataStream.Close();
WebResponse response = request.GetResponse();
Console.WriteLine(((HttpWebResponse)response).StatusDescription);
dataStream = response.GetResponseStream();
StreamReader sr = new StreamReader(dataStream);
string responseFromServer = sr.ReadToEnd();
Console.WriteLine(responseFromServer);
String[] res = responseFromServer.Split('\n');
// Clean up the streams.
sr.Close();
dataStream.Close();
response.Close();
request = WebRequest.Create("
https://www.google.com/m8/
feeds/contacts/
zabatt.com/full");
request.Method = "GET";
request.Headers.Add("GData-Version", "3.0");
request.Headers.Add("Authorization","GoogleLogin "+
res[2]);
//postData = res[2];
//byteaArray = Encoding.UTF8.GetBytes(postData);
request.ContentType = "application/atom+xml";
//request.ContentLength = byteaArray.Length;
//dataStream = request.GetRequestStream();
// dataStream.Write(byteaArray, 0, byteaArray.Length);
//dataStream.Close();
response = request.GetResponse();
Console.WriteLine(((HttpWebResponse)response).StatusDescription);
dataStream = response.GetResponseStream();
sr = new StreamReader(dataStream);
responseFromServer = sr.ReadToEnd();
Console.WriteLine(responseFromServer);
sr.Close();
dataStream.Close();
response.Close();
[/code]
Response from the last Console.WriteLine
[code]
<feed xmlns="
http://www.w3.org/2005/Atom" xmlns:openSearch="http://
a9.com/-/spec/opensearch/1.1/" xmlns:gContact="http://
schemas.google.com/contact/2008" xmlns:batch="http://
schemas.google.com/gdata/batch" xmlns:gd="
http://schemas.google.com/g/
2005" gd:etag="W/"CkMMRH09fit7I2A9WhVXGUg."">
<id>
zabatt.com</id>
<updated>2012-04-20T19:34:45.366Z</updated>
<category scheme="
http://schemas.google.com/g/2005#kind" term="http://
schemas.google.com/contact/2008#contact"/>
<title>
zabatt.com's Contacts</title>
<link rel="alternate" type="text/html" href="
http://www.google.com/"/>
<link rel="
http://schemas.google.com/g/2005#feed" type="application/
atom+xml" href="
https://www.google.com/m8/feeds/contacts/zabatt.com/
full"/>
<link rel="
http://schemas.google.com/g/2005#post" type="application/
atom+xml" href="
https://www.google.com/m8/feeds/contacts/zabatt.com/
full"/>
<link rel="
http://schemas.google.com/g/2005#batch" type="application/
atom+xml" href="
https://www.google.com/m8/feeds/contacts/zabatt.com/
full/batch"/>
<link rel="self" type="application/atom+xml" href="https://
www.google.com/m8/feeds/contacts/zabatt.com/full?max-results=25"/>
<author>
<name>
zabatt.com</name>
<email>
zabatt.com</email>
</author>
<generator version="1.0" uri="
http://www.google.com/m8/
feeds">Contacts</generator>
<openSearch:totalResults>0</openSearch:totalResults>
<openSearch:startIndex>1</openSearch:startIndex>
<openSearch:itemsPerPage>25</openSearch:itemsPerPage>
</feed>
[/code]