(Quick Reference)
Service: Save
Description: This web service is used to add a new customer category object to the database
URL:
https://BASE_URL/api/VERSION/customerCategories
Method: POST
Request content type: application/x-www-form-urlencoded or multipart/form-data
Parameters:
Name | Description | Type | Required | Example values |
---|
reference | the reference of the new customer category | String | Yes | |
name | the name of the new customer category | String | Yes | |
isRoot | destined to declare if the new category is a root or not | Boolean | No | |
parentId | represent the Id of the parent customer category | Long/String | Yes if isRoot= false or isRoot=null | |
image | image specified to the new customer category it can be jpg, gif, png, bmp | multipart | No | |
useExternalId | By default, it is set to false. set it to true if you want to use external ids. | Boolean | no | true , false |
reference must be unique
the default value of isRoot is set to false, parentId is required only if isRoot = false or isRoot = null
Success Output
Success case: response.status=201
{
"id": 60,
"name": "Preferred Customers",
"isRoot": false,
"parentId": 3,
"parentCategory": {
"id": 3,
"reference": "101",
"name": "new Categ",
"href": "/api/v1.0/customerCategories/3"
},
"reference": "102",
"description": null,
"image": null,
"organization": "Lyon",
"dateCreated": "2016-08-16T13:51:39Z",
"lastUpdated": "2016-08-16T13:51:39Z"
}
To get resized images, add prefix small_
or medium_
to the link url before the image's name, for example:
<BASE_URL>/Nice-1444810602520/photoCustomerCategory/small_1455207868614_users_crowd.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": "save_not_authorized",
"error_description": "Organization should have only one root category of customer."
}
{
"error": "save_failed",
"error_description": "Failed to save instance"
}
Failure case:response.status = 404
{
"error":"not_found",
"error_description": "The parent customer category with the id 9999 doesn't exist."
}
Failure case:response.status = 500
{
"error": "server_error",
"error_description": "Oops! Something went wrong..."
}