Update Product
Request
PUT:/{accountBookId}/product
Important Note
When a product is used in transactions, the following cannot be done:
- Updating a product with variants to a product without variants and vice versa.
- Updating product code.
- Updating product type. List of product types can be found here.
Request Parameters
Parameter | Description | Type | |
---|---|---|---|
code | Product code. | string | required |
Request Body
object: Product Input Model
Example Request Body
Omitting the field in the request body will maintain the original value of the field while leaving the field value blank will remove the existing value of the field in the product.
Update specific fields in product
Example: Update the price
value of a product to "200"
{
"product": {
"price": 200
},
"productVariant1Options": [
{},{},{}
],
"productVariant2Options": [
{},{},{}
],
"productVariants": [
{},{},{},{},{},{},{},{},{}
]
}
Number of array elements:
When updating product variant/product variant options, adding fewer array elements than the number of elements originally held by the product variant array or the product variant options array into the request body will result in removal of detail data rows.If product variant and product variant options data is to remain the same, include `productVariants`, `productVariant1Options`, and `productVariant1Options` arrays in request body with empty elements corresponding to the number of product variants and product variant options.
Example: Given the following product variant and product variants options data is to be maintained, the request body would look like this:
Sample data to be maintained
Product variant and Product variant options
productVariant1Options
productVariant1Options": [
{
"productVariantOptionId": 113,
"variantIndex": 1,
"variantOption": "Blue",
"image": null
},
{
"productVariantOptionId": 114,
"variantIndex": 1,
"variantOption": "Green",
"image": null
},
{
"productVariantOptionId": 115,
"variantIndex": 1,
"variantOption": "Red",
"image": null
}
]
productVariant2Options
"productVariant2Options": [
{
"productVariantOptionId": 116,
"variantIndex": 2,
"variantOption": "Large",
"image": null
},
{
"productVariantOptionId": 117,
"variantIndex": 2,
"variantOption": "Medium",
"image": null
},
{
"productVariantOptionId": 118,
"variantIndex": 2,
"variantOption": "Small",
"image": null
}
]
productVariants
[
{
"productVariantId": 122,
"productVariant1OptionName": "Blue",
"productVariant2OptionName": "Large",
"price": 400.00000000,
"minPrice": 350.00000000,
"stockCode": "P-00001-Blue-Large",
"barCode": null,
"image": null
},
{
"productVariantId": 123,
"productVariant1OptionName": "Blue",
"productVariant2OptionName": "Medium",
"price": 350.00000000,
"minPrice": 350.00000000,
"stockCode": "P-00001-Blue-Medium",
"barCode": null,
"image": null
},
{
"productVariantId": 124,
"productVariant1OptionName": "Blue",
"productVariant2OptionName": "Small",
"price": 350.00000000,
"minPrice": 350.00000000,
"stockCode": "P-00001-Blue-Small",
"barCode": null,
"image": null
},
{
"productVariantId": 125,
"productVariant1OptionName": "Green",
"productVariant2OptionName": "Large",
"price": 400.00000000,
"minPrice": 350.00000000,
"stockCode": "P-00001-Green-Large",
"barCode": null,
"image": null
},
{
"productVariantId": 126,
"productVariant1OptionName": "Green",
"productVariant2OptionName": "Medium",
"price": 350.00000000,
"minPrice": 350.00000000,
"stockCode": "P-00001-Green-Medium",
"barCode": null,
"image": null
},
{
"productVariantId": 127,
"productVariant1OptionName": "Green",
"productVariant2OptionName": "Small",
"price": 350.00000000,
"minPrice": 350.00000000,
"stockCode": "P-00001-Green-Small",
"barCode": null,
"image": null
},
{
"productVariantId": 128,
"productVariant1OptionName": "Red",
"productVariant2OptionName": "Large",
"price": 400.00000000,
"minPrice": 350.00000000,
"stockCode": "P-00001-Red-Large",
"barCode": null,
"image": null
},
{
"productVariantId": 129,
"productVariant1OptionName": "Red",
"productVariant2OptionName": "Medium",
"price": 350.00000000,
"minPrice": 350.00000000,
"stockCode": "P-00001-Red-Medium",
"barCode": null,
"image": null
},
{
"productVariantId": 130,
"productVariant1OptionName": "Red",
"productVariant2OptionName": "Small",
"price": 350.00000000,
"minPrice": 350.00000000,
"stockCode": "P-00001-Red-Small",
"barCode": null,
"image": null
}
]
{
"product": {...},
"productVariant1Options": [
{},{},{}
],
"productVariant2Options": [
{},{},{}
],
"productVariants": [
{},{},{},{},{},{},{},{},{}
]
}
Add a product variant
Example: Add a new "Orange" product variant under productVariant1OptionName
(Colour)
{
"product": {},
"productVariant1Options": [
{},{},{},
{
"variantOption": "Orange",
"image": null
}
],
"productVariant2Options": [
{},{},{}
],
"productVariants": [
{},{},{},{},{},{},{},{},{},
{
"productVariant1OptionName": "Orange",
"productVariant2OptionName": "Large",
"price": 400,
"minPrice": 350,
"stockCode": "P-00001-Orange-Large",
"barCode": null,
"image": null
},
{
"productVariant1OptionName": "Orange",
"productVariant2OptionName": "Medium",
"price": 350,
"minPrice": 350,
"stockCode": "P-00001-Orange-Medium",
"barCode": null,
"image": null
},
{
"productVariant1OptionName": "Orange",
"productVariant2OptionName": "Small",
"price": 350,
"minPrice": 350,
"stockCode": "P-00001-Orange-Small",
"barCode": null,
"image": null
}
]
}
Sequence of the array elements:
When updating or removing product variant/product variant options, the sequence of the elements in the data arrays matter.When updating or removing a specific array element in product variant/product variant options data arrays, remember to double check the request body before submitting the request to ensure detail data rows are not unintentionally overwritten.
In order to remove a specific product variant options and product variants from specific positions in their arrays, the input arrays need to be re-entered with the intended data.
Remove a specific product variant option and product variants
Example Data
Given the current product data:
{
"product": {
"productId": 617,
"productCode": "P-00001",
"productName": "Hoodie",
"productName2": "",
"productType": "I",
"unit": "50000",
"price": 350.00000000,
"minPrice": 350.00000000,
"cost": 200.00000000,
"productCategoryName": "Apparel",
"postingGroup": "Default",
"supplyTaxCode": "S-5",
"purchaseTaxCode": "P-5",
"tariffCode": "40159000",
"status": "A",
"image": null,
"furtherDescription": "",
"note": "",
"stockCode": null,
"supplier": "400-0001",
"variant1Name": "Colour",
"variant2Name": "Size",
"barCode": null,
"classificationCode": null,
"unitType": null,
"cannotConsolidateInvoice": false
},
"productVariant1Options": [
{
"productVariantOptionId": 156,
"variantIndex": 1,
"variantOption": "Blue",
"image": null
},
{
"productVariantOptionId": 157,
"variantIndex": 1,
"variantOption": "Green",
"image": null
},
{
"productVariantOptionId": 158,
"variantIndex": 1,
"variantOption": "Red",
"image": null
},
{
"productVariantOptionId": 162,
"variantIndex": 1,
"variantOption": "Orange",
"image": null
}
],
"productVariant2Options": [
{
"productVariantOptionId": 159,
"variantIndex": 2,
"variantOption": "Large",
"image": null
},
{
"productVariantOptionId": 160,
"variantIndex": 2,
"variantOption": "Medium",
"image": null
},
{
"productVariantOptionId": 161,
"variantIndex": 2,
"variantOption": "Small",
"image": null
}
],
"productVariants": [
{
"productVariantId": 179,
"productVariant1OptionName": "Blue",
"productVariant2OptionName": "Large",
"price": 400.00000000,
"minPrice": 350.00000000,
"stockCode": "P-00001-Blue-Large",
"barCode": null,
"image": null
},
{
"productVariantId": 180,
"productVariant1OptionName": "Blue",
"productVariant2OptionName": "Medium",
"price": 350.00000000,
"minPrice": 350.00000000,
"stockCode": "P-00001-Blue-Medium",
"barCode": null,
"image": null
},
{
"productVariantId": 181,
"productVariant1OptionName": "Blue",
"productVariant2OptionName": "Small",
"price": 350.00000000,
"minPrice": 350.00000000,
"stockCode": "P-00001-Blue-Small",
"barCode": null,
"image": null
},
{
"productVariantId": 182,
"productVariant1OptionName": "Green",
"productVariant2OptionName": "Large",
"price": 400.00000000,
"minPrice": 350.00000000,
"stockCode": "P-00001-Green-Large",
"barCode": null,
"image": null
},
{
"productVariantId": 183,
"productVariant1OptionName": "Green",
"productVariant2OptionName": "Medium",
"price": 350.00000000,
"minPrice": 350.00000000,
"stockCode": "P-00001-Green-Medium",
"barCode": null,
"image": null
},
{
"productVariantId": 184,
"productVariant1OptionName": "Green",
"productVariant2OptionName": "Small",
"price": 350.00000000,
"minPrice": 350.00000000,
"stockCode": "P-00001-Green-Small",
"barCode": null,
"image": null
},
{
"productVariantId": 185,
"productVariant1OptionName": "Red",
"productVariant2OptionName": "Large",
"price": 400.00000000,
"minPrice": 350.00000000,
"stockCode": "P-00001-Red-Large",
"barCode": null,
"image": null
},
{
"productVariantId": 186,
"productVariant1OptionName": "Red",
"productVariant2OptionName": "Medium",
"price": 350.00000000,
"minPrice": 350.00000000,
"stockCode": "P-00001-Red-Medium",
"barCode": null,
"image": null
},
{
"productVariantId": 187,
"productVariant1OptionName": "Red",
"productVariant2OptionName": "Small",
"price": 350.00000000,
"minPrice": 350.00000000,
"stockCode": "P-00001-Red-Small",
"barCode": null,
"image": null
},
{
"productVariantId": 188,
"productVariant1OptionName": "Orange",
"productVariant2OptionName": "Large",
"price": 400.00000000,
"minPrice": 350.00000000,
"stockCode": "P-00001-Orange-Large",
"barCode": null,
"image": null
},
{
"productVariantId": 189,
"productVariant1OptionName": "Orange",
"productVariant2OptionName": "Medium",
"price": 350.00000000,
"minPrice": 350.00000000,
"stockCode": "P-00001-Orange-Medium",
"barCode": null,
"image": null
},
{
"productVariantId": 190,
"productVariant1OptionName": "Orange",
"productVariant2OptionName": "Small",
"price": 350.00000000,
"minPrice": 350.00000000,
"stockCode": "P-00001-Orange-Small",
"barCode": null,
"image": null
}
]
}
Example: Remove the "Blue" variant for the given product.
The "Blue" variant's array elements are located at the top of the productVariant1Options
and productVariants
arrays.
Re-enter all data for the productVariant1Options
and productVariants
arrays without the array elements of the "Blue" variant.
{
"product": {},
"productVariant1Options": [
{
"productVariantOptionId": 157,
"variantIndex": 1,
"variantOption": "Green",
"image": null
},
{
"productVariantOptionId": 158,
"variantIndex": 1,
"variantOption": "Red",
"image": null
},
{
"productVariantOptionId": 162,
"variantIndex": 1,
"variantOption": "Orange",
"image": null
}
],
"productVariant2Options": [
{},{},{}
],
"productVariants": [
{
"productVariantId": 182,
"productVariant1OptionName": "Green",
"productVariant2OptionName": "Large",
"price": 400.00000000,
"minPrice": 350.00000000,
"stockCode": "P-000069-Green-Large",
"barCode": null,
"image": null
},
{
"productVariantId": 183,
"productVariant1OptionName": "Green",
"productVariant2OptionName": "Medium",
"price": 350.00000000,
"minPrice": 350.00000000,
"stockCode": "P-000069-Green-Medium",
"barCode": null,
"image": null
},
{
"productVariantId": 184,
"productVariant1OptionName": "Green",
"productVariant2OptionName": "Small",
"price": 350.00000000,
"minPrice": 350.00000000,
"stockCode": "P-000069-Green-Small",
"barCode": null,
"image": null
},
{
"productVariantId": 185,
"productVariant1OptionName": "Red",
"productVariant2OptionName": "Large",
"price": 400.00000000,
"minPrice": 350.00000000,
"stockCode": "P-000069-Red-Large",
"barCode": null,
"image": null
},
{
"productVariantId": 186,
"productVariant1OptionName": "Red",
"productVariant2OptionName": "Medium",
"price": 350.00000000,
"minPrice": 350.00000000,
"stockCode": "P-000069-Red-Medium",
"barCode": null,
"image": null
},
{
"productVariantId": 187,
"productVariant1OptionName": "Red",
"productVariant2OptionName": "Small",
"price": 350.00000000,
"minPrice": 350.00000000,
"stockCode": "P-000069-Red-Small",
"barCode": null,
"image": null
},
{
"productVariantId": 188,
"productVariant1OptionName": "Orange",
"productVariant2OptionName": "Large",
"price": 400.00000000,
"minPrice": 350.00000000,
"stockCode": "P-00001-Orange-Large",
"barCode": null,
"image": null
},
{
"productVariantId": 189,
"productVariant1OptionName": "Orange",
"productVariant2OptionName": "Medium",
"price": 350.00000000,
"minPrice": 350.00000000,
"stockCode": "P-00001-Orange-Medium",
"barCode": null,
"image": null
},
{
"productVariantId": 190,
"productVariant1OptionName": "Orange",
"productVariant2OptionName": "Small",
"price": 350.00000000,
"minPrice": 350.00000000,
"stockCode": "P-00001-Orange-Small",
"barCode": null,
"image": null
}
]
}
Example Request URL:
Parameters:accountBookId
= 1 code
= P-00001 URL:
PUT: https://accounting-api.autocountcloud.com/1/product?code=P-00001
Response
Success Response
Code: 204
Error Response
Response Body
object: Error Response Model
Example Error Response Body
{
"statusCode": 401,
"message": "401 Unauthorized."
}