Hisham_85


Is windows live contacts API still in beta If not where can I find complete C#/ASP samples


Re: Question

Hisham_85


This code is throwing an authorization excpetion. Can anyone help (the token is a valid token)

public static void GetContactInformation(string token)
{
String uri = "https://cumulus.services.live.com/ABC@hotmail.com/LiveContacts/Contacts";

HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri);
request.Method = "GET";
request.Headers.Add("Authorization", "DomainAuthToken at=\"" + token + "\"");
try
{
HttpWebResponse response = (HttpWebResponse)request.GetResponse(); // error occurred in this row
//request succeeded, process response
//The response body is XML: read the stream into an XML Document.
XmlDocument contacts = new XmlDocument();
contacts.LoadXml(new StreamReader(response.GetResponseStream()).ReadToEnd());
contacts.Save("MyContacts.xml");
// Do something with the returned XML data...
response.Close();
}
catch (WebException ex)
{
Console.Out.WriteLine(ex.Message);
}

}





Re: Question

Federico Raggi - MSFT

HIsham:
At first sight I can't see a problem with your code. What exception message do you receive







Re: Question

Hisham_85

Hello Federico,

Sorry for the late reply. I am getting an authorization excpetion. Any idea why




Re: Question

Hisham_85

I don't know if this is relevant, but am running the code from a console application.




Re: Question

Hisham_85

The following code throws: <error 500> Internal Server Error:

static void Main(string[] args)
{
TicketAcquirer t = new TicketAcquirer();
string ticket = t.GetTicket();

GetContacts(ticket);
}

public static void GetContacts(string token)
{
String uri = "https://cumulus.services.live.com/Email@hotmail.com/LiveContacts/Contacts";
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri);
request.Method = "GET";
request.Headers.Add("Authorization", "WLID1.0 t=" + "\"" + token + "\"");
try
{
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
XmlDocument contacts = new XmlDocument();
contacts.LoadXml(new StreamReader(response.GetResponseStream()).ReadToEnd());
contacts.Save("MyContacts.xml");
}
catch(Exception e)
{
Console.Out.WriteLine(e.Message);
}
}

Can you help




Re: Question

Federico Raggi - MSFT

Hisham:

A 500 error code indicates the Windows Live Data server had some temporary problem that prevented it from processing your request. Let me know if you still can't connect.