Add images

Last Updated: Feb 24, 2018

Description

This operation adds images to a specific image search instance. To call this operation, you must specify an instance by setting the instanceName parameter and construct the content of the POST body with the relevant parameters.

Request path

/item/add

Request parameters

URL parameters

Name Data type Required Description
instanceName String Yes Name of the instance to which the images will be added.

Body parameters

Name Data type Required Description
item_id String Yes ID of the product or image.
cat_id String Only required by product search Category ID.
cust_content String Yes Custom content.
pic_list List Yes Image name list.
pic_map Map Yes Contents of all images.

Body structure

The body structure is as following:

  1. key1,key1_start_offset,key1_end_offset#...#keyn,keyn_start_offset,keyn_end_offset^key1_content...keyn_content

The POST body includes image metadata and image content, which are separated by a circumflex accent (^). The metadata is a set of keys. All keys are separated by number signs (#). Each key includes the key name, start offset value, and end offset value, which are separated by commas (,). The start offset value and end offset value represent the start positon and end position of the cutout in the image content. The pic_list parameter must include only Base64 encoded image names, which are separated by commas (,). The pic_map parameter must include only Base64 encoded image content. Make sure all keys added to the pic_map parameter are paired with the keys added to the pic_list parameter.

Response parameters

Name Data type Description
Success Boolean Whether or not the request is successful.
RequestId String ID of the request.
Code int Error code. If the code is 0, the request is successful. If the code is not 0, the request is failed.
Message String Error information.

Response structure

  1. {
  2. "Message":"success",
  3. "RequestId":"73B5133C-84EE-4F0A-B972-23CCCBFB7CD5",
  4. "Success":true,
  5. "Code":0
  6. }

Example

The following example shows how to add product photos to an image search instance named goodssearch. In this example, product photos shoes1.jpg and shoes2.jpg are added. The content of shoes1.jpg is pic_content1. The content of shoes2.jpg is pic_content2. The product ID (item_id), category ID (cat_id), and custom content (cust_content) are specified as 1000, 0, and {“key1”:”value1”}, respectively.

  1. URL: /item/add?instaneName=goodssearch
  2. POST Body:
  3. cust_content,0,17#item_id,17,21#c2hvZXMyLmpwZw==,21,37#cat_id,37,38#pic_list,38,71#c2hvZXMxLmpwZw==,71,87^{"key1":"value1"}1000cGljX2NvbnRlbnQy0c2hvZXMyLmpwZw==,c2hvZXMxLmpwZw==cGljX2NvbnRlbnQx
  4. Note: c2hvZXMyLmpwZw== represents the Base64 encoded image name shoes1.jpg and c2hvZXMxLmpwZw== represents the Base64 encoded image name shoes2.jpg.
Thank you! We've received your feedback.