Skip to main content

Function: createEntity()

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

Defined in: src/modules/odata-http.ts:253

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.

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 });