4.3.2 Replace-Based Update by Using the Verbose JSON 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 Verbose JSON format and replace-based update semantics.
HTTP Request:
-
PUT /service.svc/Customers('ALFKI') HTTP/1.1 Host: host Content-Type: application/json;odata=verbose If-Match: W/"X'000000000000FA01'" Accept: application/json;odata=verbose Content-Length: nnn DataServiceVersion: 1.0 MaxDataServiceVersion: 3.0 Prefer: return-content {"d": { "CustomerID": "ALFKI", "CompanyName": "Updated Company Name", "Address": { "Street": "Updated Street" }, } }
HTTP Response:
-
HTTP/1.1 200 OK Date: Thurs, 4 Dec 2008 17:17:11 GMT Content-Type: application/json;odata=verbose Content-Length: nnn ETag: W/"X'000000000000FA02'" DataServiceVersion: 3.0 Preference-Applied: return-content {"d": { "__metadata": { "uri": "Customers(\'ALFKI\')", "type": "SampleModel.Customer", "etag": "W/\"X\'000000000000FA02\'\"" "properties" : { "Orders" : { "associationuri" : " Customers(\'ALFKI\')/SampleModel.Customer/$links/Orders" } } }, "CustomerID": "ALFKI", "CompanyName": "Updated Company Name", "Address": { "Street": "Updated Street", "City": "", "Location"="NULL" }, "Version": "AAAAAAAA+gF=", "Orders": { "__deferred": { "uri": "Customers(\'ALFKI\')/Orders" } } } }