getting Error 400, Bad Request when trying to use PUT (update) request of Live Contacts API

I have written an application for using Live Contacts API. GET, POST and DELETE requests are working fine for me. Am gettingError‘400’ Bad Request with ‘PUT method of Live Contacts API.PUT is working fine if am trying to only updateProfiles of the contact. But if I try to updateEmails orPhones am getting this error. Theuri that am using to create the HTTP Web request is :

https://cumulus.services.live.com/ajay.bothra@hotmail.com/LiveContacts/Contacts/Contact(86ab1cb8-85cc-413e-b488-fce444286815)

The XML File that am trying to upload is :

<?xml version="1.0" encoding="utf-8"?>

<Contact>

<Profiles>

<Personal>

<FirstName>UpdatedFirst</FirstName>

<LastName>UpdatedLast</LastName>

</Personal>

</Profiles>

<Phones>

<Phone>

<PhoneType>Mobile</PhoneType>

<Number>9898989898</Number>

</Phone>

</Phones>

</Contact>

PUT is working fine if I don’t use thePhones part. But when I try to updatePhone No.or Emails as well I get the 400 Bad Request Error. Can anyone suggest as to why is it so ?

[4827 byte] By [AjayBothra] at [2008-2-8]
# 1
Ajay:

A response code of 400 is usually associated with some invalid value on your request. In this case, the XML you are trying to PUT. Here is the description of response code 400 on the Live Contacts API documentation:

"The request cannot be executed because the request fails to comply with the required format. For example, the request contains invalid Enum values or the request attempts to update read-only values."

I would suspect something on the phone information is not valid, but I don't see what is wrong at first sight. I'll do some tests and get back to you.

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

Ajay,

There are two things you need change to make the request successful.

1) <PhoneType> is read only, according to schema. You cannot specify it during HTTP PUT.

2) Currently we donot support update with hierarchy. In order to update the phone, you have to point to phone entity directly.

So the correct request will be:

Request URI:

https://cumulus.services.live.com/ajay.bothra@hotmail.com/LiveContacts/Contacts/Contact(86ab1cb8-85cc-413e-b488-fce444286815)/Phones/Phone(2)

PUT content:

<Phone>

<Number>9898989898</Number>

</Phone>

Thanks,

- Dawei

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

Thanks Dawei. That solved the problem.

But its really bad that if i want to change more than one field (e.g. update more than one phone no.) i have to send multiple requests even if the entire data can be sent in one HTTP request. I hope update with hierarchy will be supported in the next versions of this API.

Thanks

- Ajay

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

Windows Live Developer Forums

Site Classified