# Wednesday, October 29, 2008

Now that we know how to acquire authentication ticket from Windows Live, we can put it to work accessing the user's contact list. In general a number of requests to the Live Services follow a common pattern. It is an HTTP(s) request to https://cumulus.services.live.com/{user identity}/{Service}/

Depending on the operation the request could be GET, PUT, DELETE, POST or other. User identity is the email address that is the Windows Live ID. Service can be one of the supported services. E.g. for contacts it is LiveContacts.

In order to provide the authentication ticket to the server the caller needs to include a custom HTTP header - "Authorization" and set its value to WLID1.0 t="{base64 auth ticket}" where {base64 auth ticket} is the ticket retrieved from the authentication server.

string url = "https://cumulus.services.live.com/{0}/LiveContacts/";
url = string.Format(url, userID);
string result = SendHttpRequest(ref url, string.Format("WLID1.0 t=\"{0}\"",ticket), "GET", System.Net.HttpStatusCode.OK, "", "", "");
XmlDocument docContacts = new XmlDocument();
docContacts.LoadXml(result);

The code above will retrieve the entire contact list as described here.

In order to create a contact, a POST to https://cumulus.services.live.com/{user identity}/LiveContacts/Contacts is required. The post contents should be an xml message formatted in accordance with Live contacts schema and having appropriate fields filled in. It is wort mentioning that WindowsLiveID field is not just an email address. It has to be a valid Live ID. Another thing to keep in mind is that almost any content-related error will cause HTTP code 403 (supposedly, for security reasons).

To delete a contact a DELETE verb is used. In order to indetify the contact being deleted or updated the application should use contact GUID provided in the ID tag:

<Contact>
   <
ID>ead5572c-9c61-43a2-b71f-f2412e283598</ID
>
   <
AutoUpdateEnabled>false</AutoUpdateEnabled
>
   <
LastChanged>2007-11-19T20:26:57.2230000Z</LastChanged
>
   <
Profiles
>
      <
Personal
>
         <
FirstName>Alex</FirstName
>
         <
LastName>Feinman</LastName
>
         
<Gender>Male</Gender
>
      
</Personal
>
   </
Profiles
>
</Contact
>

The post url will look like this:

https://cumulus.services.live.com/someone@example.com/LiveContacts/contacts/Contact(ead5572c-9c61-43a2-b71f-f2412e283598)

Same url format is using for updates. Keep in mind that to update data you need to use PUT verb.

Wednesday, October 29, 2008 9:41:37 AM (Pacific Standard Time, UTC-08:00)  #    Comments [1]  |