Upload video via GraphQL Admin API error

Hi Team,
I’m using GraphQL Admin API based on documentation add-media-to-a-product ,but I always get an error Invalid video, if I use domains that are not YouTube or Vimeo URL it works, seems like Shopify does not allow other domain names. or is there a place were I should specify allowed domain names . I also tried to use media content type: VIDEO same result (original source juts a sample video and i tried many different URL’s and supported format that should be mov or mp4 …)

mutation createProductMedia {
  productCreateMedia(productId: "gid://shopify/Product/1", media: [
    {
      originalSource: "http://thinkingform.com/wp-content/uploads/2017/09/video-sample-mp4.mp4",
      alt: "video-sample-mp4",
      mediaContentType: EXTERNAL_VIDEO
    }
  ]) {
    media {
      ... fieldsForMediaTypes
      mediaErrors {
        code
        details
        message
      }
      mediaWarnings {
        code
        message
      }
    }
    product {
      id
    }
    mediaUserErrors {
      code
      field
      message
    }
  }
}

fragment fieldsForMediaTypes on Media {
  alt
  mediaContentType
  preview {
    image {
      id
    }
  }
  status
  ... on Video {
    id
    sources {
      format
      height
      mimeType
      url
      width
    }
  }
  ... on ExternalVideo {
    id
    host
    originUrl
  }
  ... on Model3d {
    sources {
      format
      mimeType
      url
    }
    boundingBox {
      size {
        x
        y
        z
      }
    }
  }
}

 

According to the docs videos can only be added from:

  • Vimeo
  • Youtube
  • Hosted by Shopify

“The original source of the media object. Can be an external URL for images, YouTube videos, and Vimeo videos, or an upload URL for images, videos, and 3D models hosted by Shopify.”

So I guess you would have to upload your video to your file folder in shopify and use this url then:

https://help.shopify.com/en/manual/shopify-admin/productivity-tools/file-uploads

Are there any limitations on the number of uploaded files to Shopify? I remember some limitations based on the type of Shopify account …
After I reference the video in media as a source, can I go and delete the uploaded file, or since it is referenced it has to be in place?

I see the limitation described in this document Manage media for products

  • You’re working within the constraints of the plan-based limits for product media. There’s a limit to the number of Shopify-hosted videos and 3D models that a store can have. The limit depends on the Shopify plan that the store is on:
    • Basic Shopify: 250
    • Shopify: 1,000
    • Advanced Shopify: 5,000
    • Shopify Plus: Contact Plus Support
1 Like