Created by potrace 1.16, written by Peter Selinger 2001-2019

Miva Developer Docs

Adds a new image to a product.


Adds an image to a product and, optionally, assigns it an image type. Point it at an image file that’s already on the server, or send the image as base64 data and it creates the file for you.

Before you begin#

Note

The file must first exist on the server at the path specified before calling this function, unless a base64 encoded image is supplied via the optional Image_Data parameter. Use FTP to upload the file to the server or the Miva admin.

Example requests#

Add an image that’s on the server#

Adds the image file at graphics/00000001/logo-min.png to product 1 as image type 1.

{
    "Store_Code": "{{Store_Code}}",
    "Miva_Request_Timestamp": "{{$timestamp}}",
    "Function": "ProductImage_Add",
    "Product_ID": 1,
    "Filepath": "graphics/00000001/logo-min.png",
    "ImageType_ID": 1
}

Add a base64 encoded image#

Creates the image file at Filepath from the base64 data in Image_Data, then adds it to the product.

{
    "Store_Code": "{{Store_Code}}",
    "Miva_Request_Timestamp": "{{$timestamp}}",
    "Function": "ProductImage_Add",
    "Product_ID": 1,
    "Filepath": "graphics/00000001/NEW.jpg",
    "ImageType_ID": 1,
    "Image_Data": "ADD_BASE64_IMAGE_HERE"
}

Request parameters#

Parameter Type Required Description
product_id
Edit_Product
Product_Code
Product_SKU
Number
String
String
String
ID Number of product
Product code string
Product code string
Product SKU string
Filepath String Yes Relative file path to the image (relative to mm5 folder). The file must already exist on the server, unless Image_Data is provided.
ImageType_ID Number Yes The Id of the Image type you want to assign to the image. Pass 0 to not assign an image type.
Image_Data String No Optional. A base64 encoded image. When provided, the image file will be created from this data at the specified Filepath.

Example response#

{
    "success": 1
}

Response parameters#

Parameter Type Description
success Boolean Boolean value for if the request was successful

Error responses#

Error Code Error Message Error Description
MER-DBE-IMG-00001 Image filepaths must be local and relative to the Base Directory for Graphics Filepath is not a local relative path.
EOF Record not found: MER-DBP-PRD-00017 Product ID not found
Function Use it to
ProductImage_Delete Remove an image from a product
ProductImage_Update_Type Change the image type of a product image
ImageTypeList_Load_Query List the store’s image types
Image_Add Add an image to the store without a product
ProductList_Load_Query See a product’s images with the productimagedata on-demand column

Try in Postman#

In the Miva: JSON API: Authenticated collection, open Products > ProductImage_Add. See Set Up Postman.