REST API Product Import
Use this resource to update the Quant product database. It currently uses JSON as both input and output.
The import can only be accessed by a Quant user with the Robot role who has this Import enabled in the settings. Otherwise, the import will not be performed and the status attribute in the response will contain an error message:
HTTP 401 {"token":<TOKEN>,"status":"User is not authorized for this Resource."}
- Request
Parameter | Value |
URL | /productDataImport/json |
Debug | ?debug=true added to the URL will also display a warning in the response. Without it, only errors are listed. |
Header | Accept: application/json |
Header | Content-type: application/json |
Header | Authorization: Bearer <TOKEN> TOKEN is obtained by / authenticate (see Login). |
Method | POST |
Payload | [{id1:value1, id2:value2}, {id1:value3, id2:value4}] An array of JSON objects, in which each JSON object describes one product in Quant. |
- Attributes
Import settings are also entered on the user (see Figure 1).
Attribute | Description | Type |
Enabled | Specifies whether the automated task is active and data can be sent through it. | yes/no |
Title | Custom name of the automated task. | text |
Description | Custom description of the automatic task function. | formátted text |
Notes | Notes. | long text |
Matching Attribute | A product attribute in Quant that will help to match items from the import with products in Quant. The attribute selected here must have a mapping in the Product Attribute Mapping, otherwise the import ends with an error: HTTP 200 {"token":"<TOKEN>","status":"FAILURE","Errors":["Mapping not found for required attribute: Primary Product ID]} | selection |
Create New Products | If enabled, the import will create new products for non-existent product IDs. This option is active only when the Primary Product Id is selected in the Matching attribute. | yes/no |
Set New Products for Planogramming | If enabled, newly created products will be designed to create planograms. This option is active only when Create New Products is activated. | yes/no |
Ignore Deleted Products | If the import does not find an active product for a given ID, it searches among the deleted products by default. If it finds a deleted one, it will reactivate it. Enabling this option ignores deleted products instead of recovering them. | yes/no |
Product Attribute Mapping | A mapping containing an entry for each product attribute to be imported. This item defines the way the values from the input are interpreted (see picture below). For more details see Mapping Attribute. | complex type |
Measure Unit | Measure units such as cm, mm etc. | selection |
Decimal Point | Character separating the whole and decimal part of numbers. If a comma is selected, numeric values must also be enclosed in quotation marks because the comma separates attributes in JSON. | symbol |
String value for TRUE | Text that will be considered (regardless of case) as "Yes" for yes / no attributes. All other values are translated to "No". | text |
Date format | Date entry format, eg. 31.12.19 | selection |
- Product Attribute Mapping
- Mapping Attribute
Attribute | Description | Type |
Product Attribute | A product attribute that is update with this value. | selection |
Key | Keys texts are in JSON. | text |
Requires Approval | Changes are immediately written to the products or only created in "Quant "Changes to Approval" tab under Products in Quant, which can then be approved or rejected. | yes/no |
Value Replacement | Defines a mapping list where the text value from the input is replaced by another value before conversion to a specific attribute type. | complex type |
- Response
Parameter | Value |
Body | {"token":<TOKEN>,"status":"<STATUS>,"Total Lines":<LINE_COUNT>,"Ignored Products":<IGNORED>, "Duplicated Products":<DUPLICATED>,"Errors":[ERRORS], "Warnings":[WARNINGS]"} |
Attribute | Description | Type |
Token | User authorization token. | text |
Status | SUCCESS if everything was imported correctly and PARTIAL_SUCCESS if the import was successful, but some records were not imported and FAILURE if there was an unexpected error that stopped the import prematurely. | text |
Total Lines | Number of records on input. | number |
Ignored Products | Number of records not imported due to:
| number |
Duplicated Products | The number of records that contain the "Matching Attribute" value that previously appeared in the records. These records are ignored to prevent changes from being overwritten. | number |
Errors | An array of JSON objects describing errors. | JSON Array |
Warnings | An array of JSON objects describing the warning (only if the request contained the parameter debug = true). | JSON Array |
- Execution Log
In Quant, in addition to the import settings on the Robot, you can also view records of individual imports, including statistics, errors, warnings and general information.
If we select a specific record, we can display its details by clicking the Show items button. After marking the selected items, cllick on Download files. These files contain the input data for the given import run.
- Request
curl -H "accept: application/json" -H 'content-type: application/json' -H 'Authorization: Bearer i37YKbgCnJSXe2nvIrHA1fE8bLIE4RqROu4l1A- OTzHZXSmZ3CX'
https://[YOUR_COMPANY].iquant.eu/productDataImport/json?debug=true -d
'[{"productId":"500001","Store_ID":"1","Sales Price":"1.23"},{"productId":"500001","Store_ID":"2","Sales Price":"2.34"}]'
This example shows the update of the price of one product in two stores after previously obtaining TOKEN by logging in.
- Response
{"token":"i37YKbgCnJSXe2nvIrHA1fE8bLIE4RqROu4l1AOTzHZXSmZ3CX","status":"SUCCESS","Total Lines":2,"Ignored Products":0, "Unknwon Store IDs":0,"Warnings":["There is a mapping with empty REST Element for attribute: Club Price"]}
This response indicates a successful import with one warning. Details and statistics can then be found in Quant.