4.3.4 Merge-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 merge-based update semantics. The PATCH verb is supported only in the OData 3.0 protocol.

HTTP Request

 PATCH /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: 3.0
 MaxDataServiceVersion: 3.0
 Prefer: return-content
  
 {"d":
  {
    "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": "Seattle",
      "Location": {
        "crs": {
          "type": "name",
          "properties": { "name": "EPSG:4326" }
        },
        "type": "Point", "coordinates": [-127.9324, 49.2345]
      }
    },
    "Version": "AAAAAAAA+gF=",
    "Orders":  { "__deferred": { "uri": "Customers(\'ALFKI\')/Orders" } }
  }
 }