I am trying to add video media to product using REST API. Example below
$data = [ 'entry' => [
'id' => null,
'media_type' => 'external-video',
'label' => null,
'position' => 0,
'types' => ['image', 'small-image', 'thumbnail'],
'disabled' => false,
'content' => [
'base64_encoded_data' => base64_encode(file_get_contents('http://img.youtube.com/vi/axwE9q7llEQ/0.jpg')),
'type' => 'image/jpeg',
'name' => '0.jpg'
],
'extension_attributes' => [
'video_content' => [
'media_type' => 'external-video',
'video_provider' => 'youtube',
'video_url' => 'https://www.youtube.com/watch?v=axwE9q7llEQ',
'video_title' => 'KęKę',
'video_description' => null,
'video_metadata' => null
]
] ] ];
$ch = curl_init("http://URL/index.php/rest/V1/products/BICUMD2ndXXX036/media"); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data)); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json", "Authorization: Bearer " . json_decode($token)));
curl_exec($ch);
At the end I am receiving new media file ID but in admin I see that some fields like video url or description are empty. Any idea what I am doing wrong?