I am trying to use an existing image from one SKU and add it to another SKU. For example:

SKU0 -> Image uploaded via Admin
SKU1 -> Copy image details from SKU0 to SKU1 via API

I've tried using a PUT request to endpoint https://www.domain.com/rest/V1/products/SKU1 with input:

"product"=> [
    "sku" => "SKU1,
    "media_gallery_entries" => [
            "id" => "id of image from SKU0",
            "media_type" => "image",
            "label" => "label",
            "position" => 1,
            "disabled" => false,
            "types" => ["image"],
            "file" => "filename_sku0.jpg"

The above is also described in another example How to add product image when creating via rest api?

But I keep getting error The image content is invalid. Verify the content and try again." So I've tried adding:

"content" => [
                "base64_encoded_data" => 'encoded string here',
                "type" => "image/jpeg",
                "name" => "name of SKU0.jpg"

But all this does is duplicates the same image which is what I'm trying to avoid. Does anyone know a way of using the same image for multiple SKUS via API?


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.