Accessing Table Resources
Version 25.3.9411
Version 25.3.9411
Accessing Table Resources
Table 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 tables exposed by API Server.
GET
Use HTTP GET requests to retrieve a table or a set of tables 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 tables. The request must contain the inputs required to create the table.
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 tables.
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 tables.
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 table.