Resources

Version 23.0.9145


Resources


Resources are objects exposed in your API that can be queried, created, updated, and deleted. Resources can support the full range of create, read, update, and delete (CRUD) operations or be restricted to only a few. This topic describes the HTTP methods used to perform CRUD operations on resources exposed by API Server.

GET

Use HTTP GET requests to retrieve a resource or a set of resources from the server.

Example Request

The following is a request for an entire collection:

GET http://MyServer:MyPort/api.rsc/Cars

Corresponding Response

{
  "@odata.context": "http://MyServer:MyPort/api.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

Use HTTP POST requests to create new resources. The request must contain the inputs required to create the resource.

Example Request

The following is an example request:

POST http://MyServer:MyPort/api.rsc/Cars
{
  "Color": "Color_1", "Model": "Model_1"
}

Corresponding Response

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

PUT

Use HTTP PUT requests to update resources.

Example Request

The following is an example request:

    PUT http://MyServer:MyPort/api.rsc/Cars('Id_1')
    {
      "Color": "Color_1", "Model": "Model_1"
    }

Note: The primary key is mandatory.

Corresponding Response

{
  "@odata.context":"http://MyServer:MyPort/api.rsc/$metadata#Cars/$entity", 
  "Id": "Id_1", 
  "Color": "Color_1", 
  "Model": "Model_1"
}

DELETE

Use HTTP DELETE requests to delete resources.

Example Request

The following is an example request:

DELETE http://MyServer:MyPort/api.rsc/Cars/('Id_1')

Note: The primary key is mandatory.

Corresponding Response

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

Overriding HTTP Methods

Some clients might not be able to issue the correct HTTP method for a specific operation. You can use the @x-http-method query string input parameter or the HTTP header X-HTTP-Method to override the HTTP method for a request. For example, a client that does not support the HTTP PUT method can include the X-HTTP-Method: PUT header with a GET request to issue an update request for a resource.