CreateItem (Contact)
Last modified: March 16, 2009
Applies to: Exchange Server 2007 | Exchange Server 2010
In this article
CreateItem Request Example
Successful CreateItem Request
Invalid CreateItem Request Example
CreateItem (Contact) Error Response
The CreateItem operation is used to create contacts in the Exchange store.
Remarks
The creation of private distribution lists is not supported. All properties within the CompleteName container are read-only and cannot be set on a contact item.
CreateItem Request Example
Description
The following example of a valid CreateItem SOAP request shows how to create a contact in the default Contacts folder.
Code
<soap:Envelope
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="https://schemas.xmlsoap.org/soap/envelope/"
xmlns:t="https://schemas.microsoft.com/exchange/services/2006/types">
<soap:Body>
<CreateItem xmlns="https://schemas.microsoft.com/exchange/services/2006/messages" >
<SavedItemFolderId>
<t:DistinguishedFolderId Id="contacts"/>
</SavedItemFolderId>
<Items>
<t:Contact>
<t:FileAs>SampleContact</t:FileAs>
<t:GivenName>Tanja</t:GivenName>
<t:CompanyName>Blue Yonder Airlines</t:CompanyName>
<t:EmailAddresses>
<t:Entry Key="EmailAddress1">tplate@example.com</t:Entry>
</t:EmailAddresses>
<t:PhysicalAddresses>
<t:Entry Key="Business">
<t:Street>1234 56th Ave</t:Street>
<t:City>La Habra</t:City>
<t:State>CA</t:State>
<t: CountryOrRegion>USA</t: CountryOrRegion>
</t:Entry>
</t:PhysicalAddresses>
<t:PhoneNumbers>
<t:Entry Key="BusinessPhone">4255550199</t:Entry>
</t:PhoneNumbers>
<t:JobTitle>Manager</t:JobTitle>
<t:Surname>Plate</t:Surname>
</t:Contact>
</Items>
</CreateItem>
</soap:Body>
</soap:Envelope>
Request Elements
The following elements are used in the response:
Successful CreateItem Request
Description
The following example shows a successful response to the CreateItem request that created a contact. In this example, the response contains the identifier of the newly created item.
Code
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="https://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Header>
<t:ServerVersionInfo MajorVersion="8" MinorVersion="0" MajorBuildNumber="602" MinorBuildNumber="0"
xmlns:t="https://schemas.microsoft.com/exchange/services/2006/types" />
</soap:Header>
<soap:Body>
<CreateItemResponse xmlns:m="https://schemas.microsoft.com/exchange/services/2006/messages"
xmlns:t="https://schemas.microsoft.com/exchange/services/2006/types"
xmlns="https://schemas.microsoft.com/exchange/services/2006/messages">
<m:ResponseMessages>
<m:CreateItemResponseMessage ResponseClass="Success">
<m:ResponseCode>NoError</m:ResponseCode>
<m:Items>
<t:Contact>
<t:ItemId Id="AAAtA=" ChangeKey="EQAAAB" />
</t:Contact>
</m:Items>
</m:CreateItemResponseMessage>
</m:ResponseMessages>
</CreateItemResponse>
</soap:Body>
</soap:Envelope>
Comments
The item identifier has been shortened to preserve readability.
Successful Response Elements
The following elements are used in the response:
Invalid CreateItem Request Example
Description
The following example shows a request that contains valid XML but incompatible instructions. A contact cannot be created in a search folder.
Code
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="https://schemas.xmlsoap.org/soap/envelope/"
xmlns:t="https://schemas.microsoft.com/exchange/services/2006/types">
<soap:Body>
<CreateItem xmlns='https://schemas.microsoft.com/exchange/services/2006/messages'>
<SavedItemFolderId>
<t:DistinguishedFolderId Id='searchfolders'/>
</SavedItemFolderId>
<Items>
<t:Contact>
<t:ItemClass>IPM.Contact</t:ItemClass>
</t:Contact>
</Items>
</CreateItem>
</soap:Body>
</soap:Envelope>
CreateItem (Contact) Error Response
Description
The following example shows an error response to a CreateItem (Contact) request.
Code
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="https://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Header>
<t:ServerVersionInfo MajorVersion="8" MinorVersion="0" MajorBuildNumber="602" MinorBuildNumber="0"
xmlns:t="https://schemas.microsoft.com/exchange/services/2006/types" />
</soap:Header>
<soap:Body>
<CreateItemResponse xmlns:m="https://schemas.microsoft.com/exchange/services/2006/messages"
xmlns:t="https://schemas.microsoft.com/exchange/services/2006/types"
xmlns="https://schemas.microsoft.com/exchange/services/2006/messages">
<m:ResponseMessages>
<m:CreateItemResponseMessage ResponseClass="Error">
<m:MessageText>Cannot create a contact in a non-contact Folder.</m:MessageText>
<m:ResponseCode>ErrorCannotCreateContactInNonContactFolder</m:ResponseCode>
<m:DescriptiveLinkKey>0</m:DescriptiveLinkKey>
<m:Items />
</m:CreateItemResponseMessage>
</m:ResponseMessages>
</CreateItemResponse>
</soap:Body>
</soap:Envelope>
Error Response Elements
The following elements are used in the error response: