Magento version 2.2.5
Endpoint in question /V1/products/{sku}/media METHOD: POST
I am trying to add a video under a product sku using Magento’s provided API endpoint.
{
"entry": {
"media_type": "external-video",
"label": "Video 2",
"position": 2,
"disabled": false,
"types": ["thumbnail"],
"content" : {
"base64_encoded_data": "encoded image data ",
"type": "image/jpeg",
"name": "0.jpg"
},
"extension_attributes": {
"video_content": {
"media_type": "external-video",
"video_provider": "youtube",
"video_url": "some youtube video url",
"video_title": "some title",
"video_description": "",
"video_metadata": ""
}
}
}
The response I get from this call is “invalid option value”, I had debugged this in a local environment which leads me to failure during ProductRepository->save() within MagentoCatalogModelProductGalleryGalleryManagement.php on line 70.
Is this an issue with my payload or actual magento bug?
2
Answers
Resolved this issue by adding videos directly using POST /V1/products or PUT /V1/products/{sku} endpoints.
post method example:
I had no luck with Magento's MediaGallery POST endpoint (/V1/products/{sku}/media.
If you want to add a video to the product page then why you did not try using YouTube API?
You just need to follow these steps: