OData Operations

Version 22.0.8486


OData Operations

Version 22.0.8486


OData entities are objects exposed in your API that can be queried, created, updated, and deleted. Entities can support the full range of CRUD operations or be restricted to only a few. Entities must first be imported as tables from each connection before being exposed in the Connect API, see Managing OData Entities for more details on this.

Operations on Entities

The following HTTP methods are used to perform CRUD operations on entities exposed by CData Connect:

GET

An HTTP GET request can be used to retrieve a record or a set of records from the server. The following is an example request for an entire collection:

GET https://myconnectserver/odata.rsc/Cars

Here is the corresponding response:

{
  "@odata.context": "https://myconnectserver/odata.rsc/$metadata#Cars",
  "value": [
    { "Id": "Id_1", "Color": "Color_1", "Model": "Model_1"},
    { "Id": "Id_2", "Color": "Color_2", "Model": "Model_2"},
    { "Id": "Id_3", "Color": "Color_3", "Model": "Model_3"}
  ]
}

POST

An HTTP POST request can be used to create a new record in an entity. The request must contain the inputs required to create the record. The following is an example request:

POST https://myconnectserver/odata.rsc/Cars
{
  "Color": "Color_1", "Model": "Model_1"
}

Here is the corresponding response:

{
  "@odata.context":"https://myconnectserver/odata.rsc/$metadata#Cars",
  "value":[
    {
      "Id": "1000", 
      "Color": "Color_1", 
      "Model": "Model_2" 
    }
  ]
}

PUT

An HTTP PUT request can be used to update a record. The primary key is required. The following is an example request:

PUT https://myconnectserver/odata.rsc/Cars('Id_1')
{
  "Color": "Color_1",
  "Model": "Model_1"
}

Here is the corresponding response:

{
  "@odata.context":"https://myconnectserver/odata.rsc/$metadata#Cars/$entity",
  "Id": "Id_1",
  "Color": "Color_1",
  "Model": "Model_1"
}

DELETE

An HTTP DELETE request can be used to delete a record. The primary key is required. The following is an example request:

DELETE https://myconnectserver/odata.rsc/Cars/('Id_1')

The response is empty with a “204 No Content” HTTP status line.

Overriding HTTP Methods

Some clients may not be capable of issuing the correct HTTP method for a specific operation. You can use the @x-http-method URL parameter or the X-HTTP-Method HTTP header to override the HTTP method for a request. For example, a client that does not support the HTTP PUT method can include the HTTP request header “X-HTTP-Method: PUT” along a GET request to issue an update request for a record.