4.8 Invoking an Action

To invoke an action, a client sends an HTTP POST request to the URL that represents the action. Binding allows a client to send a POST request to a URL that represents the action with the binding parameter that is already provided.

In the following example, the binding parameter (called "Customer"; see section 6) to the CreateOrder action is the resource identified by the URL preceding the fully-qualified action name. The remaining parameters are specified in the body according to the rules specified in section 2.2.7.5.1.

Additionally, in the following request, the client optionally included an ETag for the Customer's ('ALFKI') entity. As a result, the server processes the Invoke Action request only if the ETag identifies the most up-to-date version of the entity.

HTTP Request:

        POST /Customers('ALFKI')/SampleEntities.CreateOrder HTTP/1.1
        Host: host
        Content-Type: application/json;odata=verbose
        DataServiceVersion: 3.0
        MaxDataServiceVersion: 3.0
        If-Match: ...ETag...
        Content-Length: ####
  
        {
           "quantity": 2,
           "discountCode": "BLACKFRIDAY"
        }

HTTP Response:

      HTTP/1.1 204 OK
      Date: Fri, 11 Oct 2008 04:23:49 GMT

Notice in this example that because the CreateOrder action has no ReturnType, the response code is 204 (No Content).