A space to discuss GraphQL queries, mutations, troubleshooting, throttling, and best practices.
If I try to ad an external video url to an existing product using GraphQL I received a mediaUsersErrors with the message
Invalid external video url=https://....mp4
I don't understand why, because the url is an external url on an external server (not shopify and the url is reachable and working).
I am using the mutation productCreateMedia
mutation productCreateMedia($media: [CreateMediaInput!]!, $productId: ID!) {
productCreateMedia(media: $media, productId: $productId) {
media {
mediaContentType
}
mediaUserErrors {
field
message
}
product {
id
}
}
}
and my CreateMediaInput is like that:
originalSource: "https://....mp4", alt: "video alt ", mediaContentType: "EXTERNAL_VIDEO"
Any help will be appreciated
Solved! Go to the solution
This is an accepted solution.
Thanks for clarifying!
When using the `productCreateMedia` mutation, the `CreateMediaInput.originalSource` field should be an external URL or a staged upload URL. This means that if you pass a Shopify CDN hosted URL, it will not be accepted an "external URL" and expects the staged upload URL instead.
Since videos hosted on one Shopify store with a Shopify CDN URLs, are not meant to be used to create product media on other Shopify stores, it will likely need to be downloaded and restaged in the new store.
Developer Support @ Shopify
- Was this reply helpful? Click Like to let us know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog
Hi @Pinny3 👋
The error "Invalid external video url" suggests there is an issue with the externally hosted video, for example the URL may not be publicly accessible. The `MediaUserErrorCode` can shed more light in some cases as well.
I'd recommend trying something like the below to rule out any issues with formatting the mutation/variables:
mutation productCreateMedia($media: [CreateMediaInput!]!, $productId: ID!) {
productCreateMedia(media: $media, productId: $productId) {
media {
mediaContentType
... on ExternalVideo {
id
}
}
mediaUserErrors {
code
field
message
}
product {
id
}
}
}
{
"media": {
"alt": "Shopify Unite Tour 2022",
"mediaContentType": "EXTERNAL_VIDEO",
"originalSource": "https://youtu.be/9j4_22L_j3w"
},
"productId": "gid://shopify/Product/987654321"
}
Hope that helps!
Developer Support @ Shopify
- Was this reply helpful? Click Like to let us know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog
Thanks for the update. The video itself is public available. Tried it before.
However, I will adopt the call and also going to try it wiht a youtube-link and will let you know the if it works then.
Hi there,
now I found out that I can only reference external videos from YouTube or Vimeo,
The mutation productCreateMedia works if I reference a Youtube Video.
So far, so good.
However, what I want to achieve is to use the video that is hosted by Shopify within another product in another shop from where I copy the products. And I want to use the url shopify provides like https://cdn.shopify.com/videos/...
So, is that possible and if yes how?
This is an accepted solution.
Thanks for clarifying!
When using the `productCreateMedia` mutation, the `CreateMediaInput.originalSource` field should be an external URL or a staged upload URL. This means that if you pass a Shopify CDN hosted URL, it will not be accepted an "external URL" and expects the staged upload URL instead.
Since videos hosted on one Shopify store with a Shopify CDN URLs, are not meant to be used to create product media on other Shopify stores, it will likely need to be downloaded and restaged in the new store.
Developer Support @ Shopify
- Was this reply helpful? Click Like to let us know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog