(Quick Reference)
Service: Upsert an item
Description: This web service is used to insert an item object to the database if it does not already exist, or update it.
URL with external_id:
https://BASE_URL/api/VERSION/items/reference/{id} Method: POST
Request content type: application/x-www-form-urlencoded or multipart/form-data
Parameters:
| Name | Description | Type | Required | Example values |
|---|
| reference | | String | yes | |
| name | | String | yes | |
| description | | String | no | |
| categoryId | The ID of the item category. | String | - | |
| isActive | By default, it is set to true | Boolean | no | true, false |
| isNew | | Boolean | no | true, false |
| displayOrder | | Integer | no | |
| volumeInLiter | | Double | no | 1.5 |
| pdfFile | Pdf size must be lower than 100 MB | pdf | no | |
| video | Video size must be lower than 100 MB | webm, avi, mpeg , quicktime | no | |
| image1 | Image size should not exceed 2 MB | jpg, gif, png, bmp | no | |
| image2 | Image size should not exceed 2 MB | jpg, gif, png, bmp | no | |
| image3 | Image size should not exceed 2 MB | jpg, gif, png, bmp | no | |
| tags | Tags should not contain comma seperator | JSON list | no | ["bracelet","jewelry"] |
| similarItems | List of similar items id | JSON list | no | [750,751] |
| hasSerialNumbers | By default, it is set to false | Boolean | no | true, false |
| hasDeclination | By default, it is set to false | Boolean | no | true, false |
| withLabel | By default, if isNew is true, it is set to false | Boolean | no | true, false |
| labelNote | No more than 7 characters | String | no | Faves |
| labelColor | Hexadecimal color code | String | no | #32bcb0 |
By default, if the parameter itemCategoryId is not specified, item will be added to the root item category. It will be required if there is many root categories.
Declination parameters (optional):
Parameter name: attributeValues
Parameter type: a json structure
| Name | Description | Type | Required | Example values |
|---|
| itemReference | | String | yes | |
| attributeValueId | | Integer | yes | |
Example:
attributeValues=[{itemReference:"tshirt_BLEU_S",attributeValueId:16},{itemReference:"tshirt_BLEU_S",attributeValueId:7},
{itemReference:"tshirt_ROUGE_XL",attributeValueId:6},{itemReference:"tshirt_ROUGE_XL",attributeValueId:9}]Success Output
Status: HTTP/1.1 201 Created
{
"id": 706,
"reference": "bracelet-GRP09062",
"name": "Knot Band Bracelet",
"description": null,
"itemCategoryId": 2,
"itemCategory": {
"id": 2,
"reference": "Ref-01",
"name": "Jewelry",
"href": "/api/v1.0/itemCategories/2"
},
"itemImages": null,
"displayOrder": 1,
"volumeInLiter": null,
"isActive": false,
"isNew": true,
"videoUrl": "",
"videoSize": 0,
"formattedVideoSize": "0",
"pdfUrl": "BASE_URL/entity1-1450169988465/itemPdfs/1471271200022_items_10_08_2016.pdf",
"pdfSize": 124487,
"formattedPdfSize": "121,6 Ko",
"similarItems": [],
"parentId": null,
"parentItem": null,
"hasDeclination": false,
"relatedItems": [],
"itemAttributes": [],
"tags": [],
"hasSerialNumbers": false,
"serialNumbers": null,
"organization": "entity1",
"dateCreated": "2016-08-11T09:17:30Z",
"lastUpdated": "2016-08-11T09:17:30Z"
}
Failure Output
Status: HTTP/1.1 400 Bad Request
{
"error": "save_failed",
"error_description": "Failed to save instance."
}{
"error": "not_unique",
"error_description": "reference already used"
}{
"error": "missing_param",
"error_description": "Name parameter is missing"
}{
"error": "exceeded_file_size",
"error_description": "image size should not exceed 2Mo"
}{
"error": "unsupported_file_type",
"error_description": "image format not supported."
}Status: HTTP/1.1 404 Not Found
{
"error": "not_found",
"error_description": "The Item Category with the id 2452 doesn't exist."
}