I have some youtube video urls and the matching products. How can I add the videos to the media galleries of my products, as it would be added when I do this via the backend?

I tried using the class ProductAttributeMediaGalleryManagement, but I would have to set a content value that is validated in the create method, but I have no idea to what value this should be set. I also tried to create the Entry and the VideoEntry over factories, but there I have to set a image file, otherwise I also get an exception. I don't have an image file, if I add the video via Backend it creates some placeholder image.

I just want the same behavior as when I go to the backend click Add Video, input URL, Title and Description and click Save.

2 Answers 2


this seems to be a bug in the Api.

Looking at the Rest Api Documentation of the catalogProductAttributeMediaGalleryManagementV1 Resource, the Image Content seems to be required while the Video content is optional:



You can easily add YouTube Video to Magento 2.

Generate YouTube API Key

You need to generate YouTube API key from Google Developers Console.

Integration of Youtube API key to Magento 2

Then you have to integrate YouTube API to Magento 2 by going to Configuration section from Admin Panel

Integration of Youtube Video URL to Product

Now you have to add URL of YouTube videos by going to Product section from its Admin Panel.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.