A space to discuss GraphQL queries, mutations, troubleshooting, throttling, and best practices.
I want to insert Youtube or Vimeo video via API productCreate.
My GraphQL is here
mutation productCreate($input: ProductInput!, $media: [CreateMediaInput!]) {
productCreate(input: $input, media: $media) {
product {
id
title
descriptionHtml
vendor
productType
status
collections(first:10){
edges{
node{
id
}
}
},
tags
seo{
title
description
}
variants(first: 10) {
edges {
node {
selectedOptions {
name
value
}
price
inventoryItem{
unitCost{
amount
},
tracked
}
inventoryQuantity
sku
compareAtPrice
weight
weightUnit
barcode
media(first: 10) {
edges {
node {
... on Video{
originalSource{
url
}
}
... on ExternalVideo{
embedUrl
}
... on MediaImage {
id
alt
image {
url
}
}
}
}
}
}
}
}
}
userErrors {
field
message
}
}
}
My GraphQL Variable here
{
"media": [
{
"mediaContentType": "IMAGE",
"originalSource": "https://i.ebayimg.com/thumbs/images/g/euMAAOSw-exg9ZP0/s-l300.jpg"
},
{
"mediaContentType": "IMAGE",
"originalSource": "https://mcdn.nhanh.vn/store/2071/ps/20220524/Untitled_2.jpg"
},
{
"mediaContentType":"VIDEO",
"embedUrl":"https://www.youtube.com/watch?v=ojkdEdLnIaA"
}
],
"input": {
"title": "A-T-shirt",
"descriptionHtml":"sản phẩm A-T-shirt",
"options": [
"Color", "Size"
],
"vendor":"QT",
"productType":"A-T-shirt",
"collectionsToJoin": [
"gid://shopify/Collection/394135732463"
],
"tags":["shirt", "white"],
"seo":
{
"title":"A-T-shirt",
"description":"Sale"
}
,
"variants": [
{
"mediaSrc": ["https://cdn.come/red_t_shirt.jpg"],
"options": ["Red", "M"],
"sku":"123",
"price":100,
"compareAtPrice":123,
"weight":1.0,
"weightUnit":"KILOGRAMS",
"barcode":"123",
"inventoryItem": {
"cost": 1230,
"tracked": true
},
"inventoryQuantities": {
"availableQuantity": 100,
"locationId": "gid://shopify/Location/68643782895"
}
},
{
"mediaSrc": ["https://cdn.come/red_t_shirt.jpg"],
"options": ["Red", "L"],
"sku":"123",
"price":100,
"inventoryItem": {
"cost": 1230,
"tracked": true
}
},
{
"mediaSrc": ["https://cdn.come/yellow_t_shirt.jpg"],
"options": ["Yellow", "M"],
"sku":"123",
"price":100,
"inventoryItem": {
"cost": 1230,
"tracked": true
}
},
{
"mediaSrc": ["https://cdn.come/yellow_t_shirt.jpg"],
"options": ["Yellow", "L"],
"sku":"123",
"price":100,
"inventoryItem": {
"cost": 1230,
"tracked": true
}
}
]
}
}
But it has this error: