Question

Is windows live contacts API still in beta? If not where can I find complete C#/ASP samples?
[155 byte] By [Hisham_85] at [2008-2-6]
# 1
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);
}

}

Hisham_85 at 2007-10-3 > top of Msdn Tech,Windows Live Developer Forums,Windows Live Data Development...
# 2

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

FedericoRaggi-MSFT at 2007-10-3 > top of Msdn Tech,Windows Live Developer Forums,Windows Live Data Development...
# 3
Hello Federico,

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

Hisham_85 at 2007-10-3 > top of Msdn Tech,Windows Live Developer Forums,Windows Live Data Development...
# 4
I don't know if this is relevant, but am running the code from a console application.
Hisham_85 at 2007-10-3 > top of Msdn Tech,Windows Live Developer Forums,Windows Live Data Development...
# 5
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?

Hisham_85 at 2007-10-3 > top of Msdn Tech,Windows Live Developer Forums,Windows Live Data Development...
# 6

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.

FedericoRaggi-MSFT at 2007-10-3 > top of Msdn Tech,Windows Live Developer Forums,Windows Live Data Development...

Windows Live Developer Forums

Site Classified