Home | Index

Address Book XML/JSON API Developer Guide

Examples

In the following example, the user wants to add two contacts into a category named "Friends", which might be a new category.

POST http://address.yahooapis.com/v1/addContacts
   ?format=xml
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE add-request SYSTEM "http://l.yimg.com/us.yimg.com/lib/pim/r/abook/xml/2/pheasant.dtd">
<add-request>
 <contact>
  <name>
   <first>John</first>
   <last>Doe</last>
  </name>
  <email>john.doe@example.org</email>
  <category>Friends</category>
 </contact>
 <contact>
  <name>
   <first>Jane</first>
   <last>Jones</last>
  </name>
  <email>jane.jones@example.com</email>
  <category>Friends</category>
 </contact>
</add-request>

In the following response, the first contact was merged with an existing contact in the address book. The second contact was added. In both cases, the resulting contact is returned with an additional property "add-action" indicating "merge" or "add" respectively.

<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE add-response SYSTEM "http://l.yimg.com/us.yimg.com/lib/pim/r/abook/xml/2/pheasant.dtd">
<add-response>
 <contact add-action="merge" cid="174">
  <name>
   <first>John</first>
   <last>Doe</last>
  </name>
  <address>
   <zip>94110</zip>
  </address>
  <email>john.doe@example.org</email>
  <category catid="7">Friends</category>
 </contact>
 <contact add-action="add" cid="175">
  <name>
   <first>Jane</first>
   <last>Jones</last>
  </name>
  <email>jane.jones@example.com</email>
  <category>Friends</category>
 </contact>
</add-response>

[Note] Note

In the above Response, the category entity is qualified with catid (the category-ID). The category "Friends" either already existed, or it has just been created as needed for this add/merge operation.