Create an OData request to get a single entity based on its key properties. The properties available in the response can be restricted by creating a selection, where no selection is equal to selecting all fields of the entity. Navigational properties need to be expanded explicitly by expand. Where no selection is equal to selecting all fields.

Type Parameters

Hierarchy

Implements

Constructors

  • Creates an instance of GetByKeyRequestBuilder.

    Type Parameters

    • EntityT extends Entity<EntityT>

    • DeSerializersT extends DeSerializers<any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, DeSerializersT> = DefaultDeSerializers

    Parameters

    • entityApi: EntityApi<EntityT, DeSerializersT>

      Entity API for building and executing the request.

    • keys: Record<string, any>

      Key-value pairs where the key is the name of a key property of the given entity and the value is the respective value.

    Returns GetByKeyRequestBuilder<EntityT, DeSerializersT>

Properties

_deSerializers: DeSerializersT

Dummy property to include also the deserializer type in the strucutre of the entity type.

_entity: EntityT

Dummy property whose type makes structurally identical entities distiguishable in TypeScript.

_entityApi: EntityApi<EntityT, DeSerializersT>
_entityConstructor: Constructable<EntityT>
dataAccessor: ResponseDataAccessor
entityDeserializer: EntityDeserializer
requestConfig: ODataGetByKeyRequestConfig<EntityT, DeSerializersT>

Methods

  • Add custom headers to the request. Existing headers will be overwritten.

    Returns

    The request builder itself, to facilitate method chaining.

    Parameters

    • headers: Record<string, string>

      Key-value pairs denoting additional custom headers.

    Returns GetByKeyRequestBuilder<EntityT, DeSerializersT>

  • Add custom query parameters to the request. If a query parameter with the given name already exists it is overwritten.

    Returns

    The request builder itself, to facilitate method chaining.

    Parameters

    • queryParameters: Record<string, string>

      Key-value pairs denoting additional custom query parameters to be set in the request.

    Returns GetByKeyRequestBuilder<EntityT, DeSerializersT>

  • Add a custom request configuration to the request. Typically, this is used when specifying a response type for downloading files. If the custom request configuration contains disallowed keys, those will be ignored.

    Returns

    The request builder itself, to facilitate method chaining.

    Parameters

    • requestConfiguration: Record<string, string>

      Key-value pairs denoting additional custom request configuration options to be set in the request.

    Returns GetByKeyRequestBuilder<EntityT, DeSerializersT>

  • Append the given path to the URL. This can be used for querying navigation properties of an entity. To execute a request with an appended path use executeRaw to avoid errors during deserialization. When using this, the execute method is omitted from the return type.

    Returns

    The request builder itself without "execute" function, to facilitate method chaining.

    Parameters

    • Rest ...path: string[]

      Path to be appended.

    Returns Omit<GetByKeyRequestBuilder<EntityT, DeSerializersT>, "execute">

  • Execute request.

    Returns

    A promise resolving to the requested entity.

    Parameters

    Returns Promise<EntityT>

  • Create the relative URL based on configuration of the given builder.

    Returns

    The relative URL for the request.

    Returns string

  • Sets user-defined identifier for the batch reference.

    Parameters

    • id: string

      User-defined batch reuest identifier.

    Returns void

  • Replace the default service path with the given custom path. In case of the SAP S/4HANA APIs the servicePath defaults to /sap/opu/odata/sap/<SERVICE_NAME> and can be overwritten here.

    Returns

    The request builder itself, to facilitate method chaining.

    Parameters

    • servicePath: string

      Path to override the default with.

    Returns GetByKeyRequestBuilder<EntityT, DeSerializersT>

  • Set timeout for requests towards the target system given in the destination.

    Returns

    The request builder itself, to facilitate method chaining.

    Deprecated

    Since v2.13.0. The timeout configuration is replaced by the more general middleware approach in version 3.0 of the SAP Cloud SDK.

    Parameters

    • timeout: number

      Value is in milliseconds and default value is 10000 (10 seconds).

    Returns GetByKeyRequestBuilder<EntityT, DeSerializersT>

  • Create the URL based on configuration of the given builder.

    Returns

    Promise resolving to the URL for the request.

    Parameters

    Returns Promise<string>

Copyright Ⓒ 2023 SAP SE or an SAP affiliate company. All rights reserved.