(Quick Reference) Service: Upsert an item Category

Description: This web service is used to insert an item category object to the database if it does not already exist, or update it.

URL with external_id:

https://BASE_URL/api/VERSION/itemCategories/reference/{id}

Method: POST

Request content type: application/x-www-form-urlencoded or multipart/form-data

Parameters:

NameDescriptionTypeRequiredExample values
referencethe reference of the new item categoryStringYes 
namethe name of the new item categoryStringYes 
descriptionsome details of the new categoryStringNo 
isActive BooleanNofalse
isGoodiesThe default value is set to falseBooleanNotrue
isAssetThe default value is set to falseBooleanNofalse, true
isRootthis parameter is used to declared if the new category is a root or not and by default it take false valueBooleanNofalse
parentIdthe id of the parentString 2
fileUploadimage specified to the new item category it can be jpg, gif, png, bmpmultipartNo 
displayOrderthe order of appearance of an item categoryIntegerNo5
reference must be unique
parentId is not required only if isRoot is set to true ,Or isRoot is set to false and there is exactly only one category in the database
Only one of those three attribute (isRoot,isGoodies,isAsset) can be set to true

Success Output

Success case: response.status=201
{
    "id": 257,
    "name": "new Cate",
    "isRoot": false,
    "isGoodiesCategory": false,
    "isAsset":false,
    "parentId": 255,
    "parentCategory": {
        "id": 255,
        "reference": "R100",
        "name": "Brigui",
        "href": "/api/v1.0/itemCategories/255"
    },
    "reference": "RC-999",
    "description": null,
    "image": "BASE_URL/Lyon-1447055487659/photoItemCategory/1471513158851_forfix.png",
    "organization": "Lyon",
    "displayOrder": 9,
    "isActive" : true,
    "dateCreated": "2016-08-18T09:39:18Z",
    "lastUpdated": "2016-08-18T09:39:18Z"
}

To get resized images, add prefix small_ or medium_ to the link url before the image's name, for example:

<BASE_URL>/Lyon-1447055487659/photoItemCategory/medium_1471513158851_forfix.png

Failure Output

Failure case:response.status = 400
{
    "error": "missing_param",
    "error_description": "reference parameter is missing"
}
{
    "error": "not_unique",
    "error_description": "reference already used"
}
{
     "error" : "invalid_param_type",
     "error_description" : "An invalid value was specified for parameter: isRoot (must be a boolean: true or false)"
}
{
     "error": "exceeded_file_size",
     "error_description": "image size should not exceed 2Mo"
}
{
     "error": "unsupported_file_type",
     "error_description": "image format not supported."
}
{
    "error": "invalid_param_type",
    "error_description": "An invalid value was specified for parameter: displayOrder (must be positive)"
}
{
    "error": "save_not_authorized",
    "error_description": "the item category must be either a root category or an asset or a goodie"
}
{
     "error": "save_failed",
     "error_description": "Failed to save instance"
}

Failure case:response.status = 404
{
    "error": "not_found",
    "error_description": "The parent item category with the id null doesn't exist."
}
Failure case:response.status = 500
{
    "error": "server_error",
    "error_description": "Oops! Something went wrong..."
}