Skip to main content
Version: 1.x

Function: createEntity()

createEntity<TData>(page, serviceUrl, entitySet, data, options?): Promise<ODataHttpResult<TData>>

Ai

Creates a new entity via HTTP POST.

Type Parameters​

TData​

TData = unknown

Parameters​

page​

ODataHttpPage

Playwright Page with request API.

serviceUrl​

string

OData service root URL.

entitySet​

string

Name of the entity set.

data​

unknown

Entity data to create.

options?​

ODataHttpOptions

HTTP options including required CSRF token.

Returns​

Promise<ODataHttpResult<TData>>

The created entity with HTTP status and optional ETag.

Capability​

ui5.odata.createEntity

Intent​

Create a new OData entity by sending a POST request to the service.

Guarantee​

On success, the entity is created and the response contains the created entity data with HTTP 201 status.

Ai Context​

Uses Playwright's request API to POST directly to the OData service. Requires a CSRF token obtained via fetchCSRFToken(). Supports both OData V2 and V4 response formats.

Sap Module​

sap.ui.model.odata.v2.ODataModel — HTTP-level entity creation

Business Context​

Create new business entities (e.g., purchase orders, products) via direct HTTP POST.

Throws​

ODataError with ERR_ODATA_CSRF if CSRF token is missing.

Throws​

ODataError with ERR_ODATA_REQUEST_FAILED on HTTP error.

Example​

const result = await createEntity(page, '/sap/opu/odata/sap/SVC/', 'Products', {
Name: 'Widget',
Price: 42,
}, { csrfToken: token });