CreateMediaInput isn't a defined type

samjas
New Member
1 0 0

Hi,

 

I'm fairly new to the Shopify API and GraphQL, so do excuse my noobness. I'm trying to post the following 'test' GraphQL mutation to the Admin API (content type application/json):

 

{
	"query": "mutation createProductMedia(  $id: ID!  $media: [CreateMediaInput!]!) {  productCreateMedia(productId: $id, media: $media) {    product {      id    }  }}",
	"operationName": "createProductMedia",
	"variables": {
		"id": "gid://shopify/Product/5577068413085",
		"media": [
			{
				"alt": "text",
				"originalSource": "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
				"mediaContentType": "EXTERNAL_VIDEO"
			}
		]
	}
}

 

 

However, I keep getting an error back in the response saying 'CreateMediaInput isn't a defined input type (on $media)', despite the docs (https://shopify.dev/tutorials/manage-product-media-with-admin-api#adding-media-to-a-product) saying otherwise. Even when I replace the query with the sample one given in the mentioned docs the same error is thrown. Is there anything I'm doing wrong here?

0 Likes
vix
Shopify Staff
Shopify Staff
534 105 103

You should be utilizing the graphql admin api vs. the Storefront API. Make sure you have your endpoints and auth correct. 

Vix | Developer Support @ Shopify 
 - Was my reply helpful? Click Like to let me 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

0 Likes