(Quick Reference)
Service: Create an item-unit
Description: Returns the created item-unit in json format when successful. Returns a json response, describing the failure condition when unsuccessful.
URL:
https://BASE_URL/api/VERSION/itemUnits
Method: POST
Request content type: application/json
Parameters:
Name | Description | Type | Required | Example values |
---|
itemId | The ID of item | Long/String | yes | |
unitId | The ID of unit | Long/String | yes | |
quantity | Quantity of product by unit | Integer | yes | |
salesQuantity | Quantity used in sales operations | Integer | no | |
volume | Volume of product by unit (m^3) | Double | no | 13.11 |
weight | Weight of product by unit (kg) | Double | no | 16 |
barcode | | String | no | |
expirationDate | The expiration date field is automatically filled if the bar code meets the standard EAN 128 | Date | no | 2016-08-31 |
isDefault | This parameter is required when item don't have a default unit, otherwise it is set to false by default. | Boolean | - | true, false |
defaultDisplay | | Boolean | no | true, false |
unpacking | this parameter is set to false by default. | Boolean | no | true, false |
useExternalId | By default, it is set to false. set it to true if you want to use external ids. | Boolean | no | true , false |
Every item must have only one default unit.
Success Output
Success case: response.status = 201
{
"id": 92,
"itemReference": "bracelet-GRP09062",
"unitReference": "PACKET",
"item": {
"id": 497,
"reference": "bracelet-GRP09062",
"name": "Knot Band Bracelet",
"href": "/api/v1.0/items/497"
},
"unit": {
"id": 7,
"reference": "PACKET",
"name": "packet",
"href": "/api/v1.0/units/7"
},
"quantity": 4,
"salesQuantity": 1,
"volume": null,
"weight": null,
"barcode": null,
"expirationDate": null,
"isDefault": false,
"defaultDisplay": false,
"organization": "entity1",
"dateCreated": "2016-08-24T09:17:24Z",
"lastUpdated": "2016-08-24T09:17:24Z"
}
Failure Output
Failure case:response.status = 400
{
"error": "already_assigned",
"error_description": "Item is already assigned to unit."
}
{
"error": "is_default_error",
"error_description": "Item has already a default unit."
}
{
"error": "date_validation_error",
"error_description": "incorrect expiration date Format"
}
{
"error": "invalid_param_type",
"error_description": "An invalid value was specified for parameter: weight (must be Positive Double)"
}
{
"error": "refused_value",
"error_description": "Sales quantity should be equal to 1."
}
{
"error": "json_parsing_error",
"error_description": "A JSON parsing error occurred while parsing request parameters."
}
Failure case:response.status = 404
{
"error": "not_found",
"error_description": "The item with the id 123 doesn't exist."
}
{
"error": "not_found",
"error_description": "The unit with the id 70 doesn't exist."
}
Failure case:response.status = 500
{
"error": "server_error",
"error_description": "Oops! Something went wrong..."
}