Invalid URL when attaching videos to a product

Hi!

I’m trying to upload and attach a video to a product by following this guide: https://help.shopify.com/en/api/guides/media

I successfully obtained the credentials, then sent the upload request to the given S3 bucket and received an URL of the uploaded asset. Now I’m trying to attach it to a product using the productCreateMedia GraphQL mutation (I’m using the unstable API version):

		mutation createProductMedia($id: ID! $media: [CreateMediaInput!]!) {
			productCreateMedia(productId: $id, media: $media) {
				media {
					status
					... on Video {
						id
					}
					... on ExternalVideo {
						id
					}
					mediaErrors {
						code
						details
						message
					}
				}
				userErrors {
					field
					message
				}
			}
		}

with following variables:

{ 
   "id":"gid://shopify/Product/4163879075922",
   "media":[ 
      { 
         "originalSource":"https://shopify-video-production-core-originals.s3.amazonaws.com/c/o/v/8497841fa3794b098b2a41a8ad3353c4.mp4",
         "mediaContentType":"VIDEO"
      }
   ]
}

But every time I send the request I get the following error from the API:

{
  "data": {
    "productCreateMedia": {
      "media": [],
      "userErrors": [
        {
          "field": [
            "media",
            "0",
            "originalSource"
          ],
          "message": "Invalid video url=https://shopify-video-production-core-originals.s3.amazonaws.com/c/o/v/8497841fa3794b098b2a41a8ad3353c4.mp4"
        }
      ]
    }
  },
  "extensions": {
    "cost": {
      "requestedQueryCost": 11,
      "actualQueryCost": 10,
      "throttleStatus": {
        "maximumAvailable": 1000,
        "currentlyAvailable": 990,
        "restoreRate": 50
      }
    }
  }
}

Is it a bug in the API? Or should I use some different value as an originalSource variable when attaching the video to the product?

Thanks in advance for any help!

Hi, @kryniol ,

This is Evita from On The Map.

It looks like your video URL is broken.

Best,
Evita

I think you should use the “resourceUrl” you’re getting back from the stagedUploadsCreate mutation,

and from the looks of it it seems you are sending the url field instead.

Amos

Thank you @amosmos VERY VERY VERY much! I owe you one! Now it works like a charm :slight_smile:

Happy to help :slight_smile: