Hi,
I think you are missing a ReadToEnd() to get the content from the
Stream:
restResponse = (HttpWebResponse)restRequest.GetResponse
();
StreamReader responseStream = new StreamReader
(restResponse.GetResponseStream());
string content = responseStream.ReadToEnd();
In the other hand, I recommend you to try the Contacts .NET client
library:
http://code.google.com/apis/contacts/docs/1.0/developers_guide_dotnet.html
Authentication would be easier, for example:
ContactsService service = new ContactsService("exampleCo-
exampleApp-1");
service.setUserCredentials("[email protected]", "password")
Cheers,
Julian.
On Mar 11, 9:45 am, "M. FarouQ" <[email protected]> wrote:
> Greetings,
>
> I'm trying to consume the Contacts feeds programmatically
> using .NET for HOSTED accounts but I must first perform an HTTP
> ClientLogin request. I was wondering if it's possible to do this
> programmatically as well using .NET's HttpWebRequest.
>
> My code looks like this:
>
> HttpWebRequest restRequest;
> HttpWebResponse restResponse;
>
> string accountType = "HOSTED";
> string Email = "[email protected]";
> string Passwd = "pass";
> string service = "cp";
> string source = "exampleCo-exampleApp-1";
>
> ASCIIEncoding encoding=new ASCIIEncoding();
> string postData="accountType="+accountType;
> postData += ("&Email="+Email);
> postData += ("&Passwd="+Passwd);
> postData += ("&service="+service);
> postData += ("&source="+source);
> byte[] data = encoding.GetBytes(postData);
>
> restRequest = (HttpWebRequest)
> WebRequest.Create("https://www.google.com/accounts/ClientLogin");
>
> restRequest.Method = "POST";
> restRequest.ContentType="application/x-www-form-urlencoded";
> restRequest.ContentLength = data.Length;
> Stream newStream = restRequest.GetRequestStream();
> newStream.Write(data,0,data.Length);
> newStream.Close();
>
> restResponse = (HttpWebResponse)restRequest.GetResponse();
> Stream responseStream = response.GetResponseStream();
> --------------------------------
>
> But for some reason the responseStream is not returning the three
> tokens "Auth", "SID" and "LSID" which I need to be able to fetch the
> private contact feeds.
>
> Any help would be appreciated. Thanks
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Contacts API" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/google-contacts-api?hl=en
-~----------~----~----~----~------~----~------~--~---