4.3.1 Replace-Based Update by Using the AtomPub Format

The following example illustrates the exchange of messages that is required for a client to update an existing entity in a data service by using the AtomPub format and replace-based update semantics.

HTTP Request:

 PUT /service.svc/Customers('ALFKI') HTTP/1.1
 Host: host
 Content-Type: application/atom+xml
 If-Match: W/"X'000000000000FA01'"
 Accept: application/atom+xml
 Content-Length: nnn
 DataServiceVersion: 1.0
 MaxDataServiceVersion: 3.0
 Prefer: return-content       
 <?xml version="1.0" encoding="utf-8"?>
 <entry xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices"
        xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"
        xmlns="http://www.w3.org/2005/Atom">
   <content type="application/xml">
    <m:properties>
     <d:CustomerID>ALFKI</d:CustomerID>
     <d:CompanyName>Updated Company Name</d:CompanyName>
     <d:Address>
       <d:Street>Updated Street</d:Street>
     </d:Address>
    </m:properties>
   </content>
 </entry>

HTTP Response:

 HTTP/1.1 200 OK
 Date: Thurs, 4 Dec 2008 17:17:11 GMT
 Content-Type: application/atom+xml;type=entry
 Content-Length: nnn
 ETag: W/"X'000000000000FA02'"
 DataServiceVersion: 3.0
 Preference-Applied: return-content
  
 <?xml version="1.0" encoding="utf-8"?>
 <entry xml:base="http://host/service.svc/"
        xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices"
        xmlns:gml=http://schemas.opengis.net/gml/3.1.1/profiles/gmlsfProfile/1.0.0/gmlsf.xsd
        xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"
        xmlns="http://www.w3.org/2005/Atom">
   <category term="SampleModel.Customer"
             scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme"/>
   <id>http://host/service.svc/Customers('ALFKI')</id>
   <title type="text" />
   <updated>2008-04-30T17:17:11Z</updated>
   <author>
     <name />
   </author>
   <link rel="edit" title="Customers" href="Customers('ALFKI')/SampleModel.Customer" />
   <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Orders"
         type="application/atom+xml;type=feed"
         title="Orders"
         href="Customers('ALFKI')/SampleModel.Customer/Orders" />
   <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/relatedlinks/Orders"
         type="application/xml "
         title="Orders"
         href="Customers('ALFKI')/SampleModel.Customer/$links/Orders" />
   <content type="application/xml">
    <m:properties>
     <d:CustomerID>ALFKI</d:CustomerID>
     <d:CompanyName>Updated Company Name</d:CompanyName>
     <d:Address>
       <d:Street>Updated Street</d:Street>
       <d:City></d:City>
       <d:Location m:type="Edm.GeographyPoint"></d:Location>
     </d:Address>
     <d:Version>AAAAAAAA+gF=</d:Version>
    </m:properties>
   </content>
 </entry>