POST /api/:space/unitofmeasure

Description:

Create a new unit of measure.

Resource URL:

https://<apphost>.competitionlabs.com/api/<your-space-name>/unitofmeasure

Request headers

KeyValueRequired
X-API-KEY
Your unique API keyYes
Content-Type
application/jsonYes

Request URL parameters

Parameter
Type
Required
Description
space
StringYes

This is the space name which is linked to the account


Post body parameters

Parameter
Type
Required
Description
name
String

Yes

The name of a unit of measure
key
StringYes

The reference to the unit of measure in your system

description
StringOptional

The description of a unit of measure

isoCode
StringOptional

An alphabetical or numerical code to identify a unit of measure

symbol
StringOptionalThe symbol of a unit of measure
multiplier
DoubleYesIs used to multiply the value from the standardised one that is being used
unitOfMeasureType
StringYesA type of unit of measure, eg. Currency, Mass, Time and etc. 
metadata
Array [Object]Optional

A list of MetaData. An object of key value pair (KVP):

ParameterTypeRequiredDescription
keyStringYesIs a unique identifier
valueArray [String]YesThe data that is identified.

EXAMPLE

Request
curl
--header "X-API-KEY: <your-api-key>"
--header "Content-Type: application/json"
--request POST https://app.competitionlabs.com/api/<your-space-name>/unitofmeasure
-d '{ "name": "test", "key": "test", "description": "test", "isoCode": "T", "symbol": "T", "multiplier": 1.0, "unitOfMeasureType": "Distance", "metadata": [{ "jsonClass": "Metadata", "key": "key", "value": "1" }], "translations": {}, "translatableFields": [ "name", "description" ]}'
Response
{
    "data": {
        "jsonClass": "UnitOfMeasure",
        "name": "test",
        "key": "test",
        "description": "test",
        "isoCode": "T",
        "symbol": "T",
        "multiplier": 1.0,
        "unitOfMeasureType": "Distance",
        "metadata": [
            {
                "jsonClass": "Metadata",
                "key": "key",
                "value": "1"
            }
        ],
        "accountId": "0sn4DmUBkPH_lz9GgxBM",
        "created": "2019-09-20T09:11:05.270+0000",
        "id": "l-TwTW0BBZeE7Tj3bRM4",
        "translations": {},
        "translatableFields": [
            "name",
            "description"
        ]
    }
}

ERROR CODES

CodeHTTP StatusDescriptionExample
1021409Duplicate unit of measure found
Error Response 409
{
    "errors": [
        {
            "message": "Duplicate record found",
            "code": 2026,
            "status": 409
        }
    ]
}
1001400
  • Unit Of Measure Type parameter was excluded;
  • Unit Of Measure Type parameter was incorrect;
  • Multiplier parameter was excluded;
  • Name parameter was excluded;
  • Key parameter was excluded;
Error Response 400
{
    "errors": [
        {
            "message": "Malformed JSON body.",
            "code": 1001,
            "status": 400
        }
    ]
}

404Adding anything extra to the Resource URL
Error Response 400
{
    "status": 404
}
1002404
  • The parameter Name can not be empty;
  • The parameter Key can not be empty;
Error Response 400
{
    "errors": [
        {
            "message": "Please enter a name for the unit of measure.",
            "code": 1002,
            "status": 404
        }
    ]
}
Error Response 400
{
    "errors": [
        {
            "message": "Please enter a key for the unit of measure.",
            "code": 1002,
            "status": 404
        }
    ]
}