Unit management
Manage Units
Retrieves a list of units conforming with the given filters. Supports sorting and paging.
If the
Accept-Languageis set to*each internationalized field is returned as a map that contains all of translations in a format ofkey:valuepairs, where thekeyis the language code andvalueis the translation.The
Accept-Languagecan contain the priority list of languages which should be returned. Always one language is returned as a single string field. Example: 'fr-CH, fr;q=0.9, en;q=0.8, de;q=0.7'If the
Accept-Languageheader is empty default language defined in theConfiguration serviceis taken.If the unit name matches none of the specified languages, an empty string is returned in the name field.
- : Needed to manage measurement units.
The tenant name.
Note: params is not a name of query param. Any API model field can be taken as a filtering parameter.
Filtering can be done by each field available in API. Filtering by multiple fields is also allowed. In that case, fields are aggregated with AND logic operator.
- In a case of string values, the
containsapproach is taken (filtering by substrings). - In a case of boolean and number fields, the
equalsapproach is taken.
Filtering query params examples:
type=mass- all units withtypethat containsmassare returned. For example, in that case all mass units will be returned.type=a- all units withtypethat containsaare returned. For example, in that case allmassanddistanceunits are returned.factor=1- all units withfactorthat equals1are returned.baseUnit=true- all units withbaseUnitthat equalstrueare returned.type=mass&name=gram- all units withtypethat containsmassANDnamethat containsgramare returned. For example, in that casekilogram,gram,decagramunits are returned.
Filtering by localized fields:
-
Filtering by localized fields without language key is possible only when
Accept-Languageheader with correct language is provided or when it is not set at all (in that case the default language is taken). For example, whenAccept-Languageis set to 'en', the request with parametername=meterreturns all units withnamethat containsmeterin English. For example, in that casemeter,kilometerandmillimeterunits are returned. -
When
Accept-Languageheader is set to*filtering by localized fields is possible only when fields contains a language key. For example, whenAccept-Languageis set to '*', the request with parametername.en=meterreturns all units withname.enthat containsmeterin English. For example, in that casemeter,kilometerandmillimeterunits are returned.
Fields to sort the response data by following order of the parameters from left to right.
Can contain multiple fields in format: field name:sort direction separated by a comma.
- The colon with
sort directionparameter is redundant and descending order is taken only if it's equal todescorDESC. - Ascending order is considered in any other case.
Sorting by
nameparameter works properly only if theAccept-Languageheader is set to a specific language or is empty with default language specified in the configuration service.
name,factor:asc,metadata.createdAt:descThe page number to be displayed.
1Number of units on a single page.
60The Accept-Language request HTTP header defines which languages the client is able to understand, and which locale variant is preferred. If empty, English language is returned. It can be a priority list working as a fallback mechanism.
fr-CH, fr;q=0.9, en;q=0.8, de;q=0.7Total count flag. If set to true, the X-Total-Count header is returned.
trueThe units were retrieved successfully.
Example response
Given request is unauthorized - the authorization token is invalid or has expired.
Details will be provided in the response payload.
Unexpected server error
Creates a new unit. After successful creation, the unit is visible and executable for other parts of the system after 5 minutes.
If the
Content-Languageis set to*the request body payload should contain localized fields not as a string, but as a map in format:key:value, where thekeyis the language code andvalueis the translation.
Required scopes
unithandling.unit_manage
- : Needed to manage measurement units.
The tenant name.
The Content-Language request HTTP header defines language(s) of the payload.
frThe unit code.
gThe name of the unit in the form of a map (language, value) or string.
The type of a unit.
massThe symbol of a unit.
°CThe base unit flag.
trueThe conversion factor. The factor value must be greater than zero.
1The unit has been successfully created.
Example response
Given request is unauthorized - the authorization token is invalid or has expired.
Details will be provided in the response payload.
Given authorization scopes are not sufficient and do not match scopes required by the endpoint.
The unit already exists.
Unexpected server error
- : Needed to manage measurement units.
The tenant name.
The units have been successfully deleted.
The units cannot be deleted due to no payload.
Given request is unauthorized - the authorization token is invalid or has expired.
Details will be provided in the response payload.
Given authorization scopes are not sufficient and do not match scopes required by the endpoint.
Unexpected server error
No content
Retrieves the unit with the given code.
If the
Accept-Languageis set to*each internationalized field is returned as a map that contains all of translations in a format ofkey:valuepairs, where thekeyis the language code andvalueis the translation.The
Accept-Languagecan contain the priority list of languages which should be returned. Always one language is returned as a single string field.If the
Accept-Languageheader is empty default language defined in theConfiguration serviceis taken.If the unit name matches none of the specified languages, an empty string is returned in the name field.
- : Needed to manage measurement units.
The code of the unit.
gThe tenant name.
The Accept-Language request HTTP header defines which languages the client is able to understand, and which locale variant is preferred. If empty, English language is returned. It can be a priority list working as a fallback mechanism.
fr-CH, fr;q=0.9, en;q=0.8, de;q=0.7Returns the given unit.
Example response
Given request is unauthorized - the authorization token is invalid or has expired.
Details will be provided in the response payload.
The unit has not been found.
Unexpected server error
Updates an existing unit. Optimistic locking is applied to prevent update races when unit in the payload contains the optional version field. After successful update, the unit is visible and executable for other parts of the system after 5 minutes.
If the
Content-Languageis set to*the request body payload should contain localized fields not as a string, but as a map in format:key:value, where thekeyis the language code andvalueis the translation.
Required scopes
unithandling.unit_manage
- : Needed to manage measurement units.
The code of the unit.
gThe tenant name.
The Content-Language request HTTP header defines language(s) of the payload.
frThe unit has been updated successfully.
The unit cannot be updated due to an incorrect payload.
Given request is unauthorized - the authorization token is invalid or has expired.
Details will be provided in the response payload.
Given authorization scopes are not sufficient and do not match scopes required by the endpoint.
The unit has not been found.
Unexpected server error
No content
- : Needed to manage measurement units.
The code of the unit.
gThe tenant name.
The unit has been successfully deleted.
Given request is unauthorized - the authorization token is invalid or has expired.
Details will be provided in the response payload.
Given authorization scopes are not sufficient and do not match scopes required by the endpoint.
The unit has not been found.
Unexpected server error
No content
Last updated
Was this helpful?

