"Invalid external video url" when using productCreateMedia

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",](https://....mp4",) alt: "video alt ",
 mediaContentType: "EXTERNAL_VIDEO"

Any help will be appreciated

Hi @Pinny3 :waving_hand:

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](https://shopify.dev/api/admin-graphql/2022-10/enums/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!

1 Like

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?

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.

1 Like