When I add a product via the Magento 2 API and then add an image, the image is added and shows up under the "Images and Videos" tab, associated with the correct product. However, none of the Image Roles (Base/Small/Thumbnail/Swatch) are selected, so the image does not show up on the site or the search results in the Magento admin.

I am sending a POST request to:

CURLOPT_URL => $URL . "/rest/default/V1/products/".$sku."/media"

$image_post_data = [
                "entry"=> [
                    "label"=> "Image".$sku,
                    "position"=> 0,
                    "disabled"=> "false",
                    "types"=> [
                    "content"=> [
                        "base64EncodedData"=> $image64,
                        "type"=> "image/jpeg",
                        "name"=> $sku."jpg"

Thinking that it might be an issue with the POST command, I then try a PUT afterwards:

$requestUrl = 'http://MYSTORE.com/index.php/rest/V1/products/'.$sku.'/media/'.$imageid;

$put_data = [
    "entry"=> [
        "id"=> $imageid,
        "position"=> 1,
        "types"=> ["image", "small_image", "thumbnail", "swatch_image"]                                

This also does not enable the image roles/types. I'm not getting an error back and everything looks fine. I can update the position and label using the PUT code successfully.

Any idea what I'm missing?

  • did you try to send the images directly by the Save product endpoint? this worked for me – WISAM HAKIM Jun 11 '19 at 2:44
  • I'm having trouble finding the Save product endpoint in the list of REST API endpoints; do you have any further info on this? Thank you! – Ryan Shenk Jun 11 '19 at 12:44
  • it is under "catalogProductRepositoryV1 ", post /V1/products – WISAM HAKIM Jun 12 '19 at 13:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.