Resources
Version 23.0.8844
Resources
Version 23.0.8844
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 section describes the HTTP methods used to perform CRUD operations on resources exposed by the API Server.
GET
An HTTP GET request can be used to retrieve a resource or a set of resources from the server. The following is an example request for an entire collection:
GET http://MyServer:MyPort/api.rsc/Cars
Here is the 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
An HTTP POST request can be used to create a new resource. The request must contain the inputs required to create the resource. The following is an example request:
POST http://MyServer:MyPort/api.rsc/Cars
{
"Color": "Color_1", "Model": "Model_1"
}
Here is the corresponding response:
{
"@odata.context":"http://MyServer:MyPort/api.rsc/$metadata#Cars",
"value": [
{
"Id": "1000",
"Color": "Color_1",
"Model": "Model_2"
}]
}
PUT
An HTTP PUT request can be used to update a resource. The primary key is required. The following is an example request:
PUT http://MyServer:MyPort/api.rsc/Cars('Id_1')
{
"Color": "Color_1", "Model": "Model_1"
}
Here is the corresponding response:
{
"@odata.context":"http://MyServer:MyPort/api.rsc/$metadata#Cars/$entity",
"Id": "Id_1",
"Color": "Color_1",
"Model": "Model_1"
}
DELETE
An HTTP DELETE request can be used to delete a resource. The primary key is required. The following is an example request:
DELETE http://MyServer:MyPort/api.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 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.