4.2.9 Retrieve a Single Entity Exposing an Action by Using the Verbose JSON Format

The following example illustrates the exchange of messages that is required for a client to retrieve a Customer entity with EntityKey value equal to "ALFKI" by using the Verbose JSON format. The server indicates that the returned Customer allows an action (CreateOrder) to be invoked against it. Actions are supported only in the OData 3.0 protocol.

Request:

 GET /service.svc/Customers('ALFKI') HTTP/1.1
 Host: host
 Accept: application/json;odata=verbose
 DataServiceVersion: 1.0
 MaxDataServiceVersion: 3.0

Response:

 HTTP/1.1 200 OK
 Date: Fri, 12 Dec 2008 17:17:11 GMT
 Content-Type: application/json;odata=verbose
 Content-Length: nnn
 ETag: W/"X'000000000000FA01'"
 DataServiceVersion: 3.0
  
 {"d":
  { 
    "__metadata": { 
        "uri": "Customers(\'ALFKI\')", 
        "type": "SampleModel.Customer",
        "etag": "W/\"X\'000000000000FA01\'\"" 
        "properties" : {
            "Orders" : {
               "associationuri" : "Customers(\'ALFKI\')/SampleModel.Customer/$links/Orders",
            }
        },
        "actions" : {
            "SampleEntities.CreateOrder" : [{
                "title" : "Create Order",
                "target" : "Customers(\'ALFKI\')/SampleEntities.CreateOrder"
            }]
        }
    },  
    "CustomerID": "ALFKI", 
    "CompanyName": " Alfreds Futterkiste", 
    "Address": { "Street": "57 Contoso St", "City": "Seattle",
      "Location": {
        "crs": {
          "type": "name",
          "properties": { "name": "EPSG:4326" }
        },
        "type": "Point", "coordinates": [-127.9324, 49.2345]
      }
    },
    "Version": "AAAAAAAA+gE=",
    "Orders":  { "__deferred": { "uri": "Customers(\'ALFKI\')/SampleModel.Customer/Orders" } }
  }
 }