OData Service consumption is standardized.
SAP Business ByDesign provides mainly two OData interfaces:
- OData for Analytics allows to execute and retrieve the result of Business Analytics Reports.
- Modeled OData services are based on Business Objects (BO) and support Create, Retrieve, Update, and Delete (CRUD) operations as well as Function Imports to access BO queries and BO actions.
It depends on the used programming language, environment and framework, how the modeled OData service can be accessed, that is: how an HTTP request can be triggered.
Usage is similar/equal in all cases: An HTTP request to the URL (Collection, Entity, or Function Import) with the according HTTP method is created, and (field, value) data and/or options are passed as required.
The service responds with a status code and according data, if available.
- In case of success, a success status code 2xx is returned.
- In case of error, an error status code 4xx/5xx is returned depending on the type or error.
Operation |
HTTP method |
URL: .../sap/byd/odata/cust/v1/your_service |
Status Code |
Retrieve (any) |
GET |
/YourCollection |
200 |
Retrieve (single) |
GET |
/YourCollection('ObjectID') |
200 |
Create |
POST |
/YourCollection |
201 |
Update (Replace) |
PUT |
/YourCollection('ObjectID') |
204 |
Update (Modify) |
PATCH/MERGE |
/YourCollection('ObjectID') |
204 |
Delete |
DELETE |
/YourCollection('ObjectID') |
200 |
Function Import |
as modeled |
/YourFunctionImportName |
200/204 |
Status codes:
Status Code |
Description |
Data returned |
200 |
Ok |
Yes |
201 |
Created |
Yes |
204 |
No content |
No |
4xx/5xx |
Depends on error |
Depends on error |
More details and examples:
HTTP Methods
Direct support is best only for GET and POST. All other methods PUT/PATCH/MERGE/DELETE may or may not be supported. Servers, proxies, and clients often do not support them directly. Sometimes they are rejected by a firewall.
For best compatibility, send a POST request and set header x-http-method to the according method.
Wanted Method |
Request Method |
GET |
GET |
POST |
POST |
Wanted Method |
Request Method |
With header x-http-method |
PUT |
POST |
PUT |
PATCH or MERGE |
POST |
PATCH or MERGE |
DELETE |
POST |
DELETE |
- If it is PATCH or MERGE depends on the available support.
- Besides x-http-method the header x-http-method-override could be evaluated.
For SAP Business ByDesign uses request method POST and header x-http-method MERGE.
Create
Instances are created with a POST request. The created instance is returned.
The OData Framework supports the creation of hierarchies. For example the supplied data could specify a ROOT node with one or even multiple ITEM nodes and/or other child nodes.
The framework responds with the topmost created node. The hierarchy needs to be read if required.
Request |
Method |
POST |
URL |
.../sap/byd/odata/cust/v1/your_service/YourCollection |
Data |
The (attribute, value) data to use |
Response (Success) |
Status |
201 (created) |
Data |
Created node. If a hierarchy was created, the topmost created node. |
Response (Error) |
Status |
4xx/5xx depending on problem |
Data |
Details on problem, if available |
Retrieve
Data is retrieved with a GET request. The URL describes what is exactly retrieved. Therefore the result could be 0, 1 or many entries.
Request |
Method |
GET |
URL (any) |
.../sap/byd/odata/cust/v1/your_service/YourCollection |
URL (single) |
.../sap/byd/odata/cust/v1/your_service/YourCollection(‘ObjectID’) |
Data |
Optional: Parameters to describe the requested data |
Response (Success) |
Status |
200 (ok) |
Data |
The requested data |
Response (Error) |
Status |
4xx/5xx depending on problem |
Data |
Details on problem, if available |
Update
Data is updated with a PUT, or PATCH or MERGE request. The difference is the scope of the modification.
- PUT replaces the data. Provided fields are modified, unstated are reset to their defaults.
- PATCH (or MERGE) modifies only the provided fields.
A BO modify is done. Hence other fields or nodes could have been changed as a consequence.
Request |
For best compatibility |
Method |
PUT or PATCH or MERGE |
POST, with x-http-method PUT, or PATCH or MERGE |
URL |
.../sap/byd/odata/cust/v1/your_service/YourCollection(‘ObjectID’) |
Data |
The (attribute, value) data to use |
Response (Success) |
Status |
204 (no content) |
Data |
- |
Response (Error) |
Status |
4xx/5xx depending on problem |
Data |
Details on problem, if available |
Delete
An instance is removed with a DELETE request, based on the ObjectID.
Request |
For best compatibility |
Method |
DELETE |
POST, with x-http-method DELETE |
URL |
.../sap/byd/odata/cust/v1/your_service/YourCollection(‘ObjectID’) |
Data |
- |
Response (Success) |
Status |
204 (no content) |
Data |
- |
Response (Error) |
Status |
4xx/5xx depending on problem |
Data |
Details on problem, if available |
Function Imports
Request, as configured in OData modeler |
For best compatibility |
Method |
GET or DELETE or POST or PUT |
GET, POST, or POST with x-http-method PUT or DELETE |
URL |
.../sap/byd/odata/cust/v1/your_service/YourFunctionImportName |
Data |
(attribute, value) data as required by the Function import |
Response (Success) |
Status |
200 (ok) or 204 (no content) |
Data |
The requested data, if available |
Response (Error) |
Status |
4xx/5xx depending on problem |
Data |
Details on problem, if available |
Language and framework examples: