Hello,
As the title says I’m having issues uploading media files to my products.
Steps to recreate:
First is to use the stagedUploadsCreate
mutation
Second step is to use productCreateMedia
and assign it to the prouct
I don’t have any errors and my response from the productCreateMedia is
{"data":{"productCreateMedia":{"media":[{"alt":"","mediaContentType":"IMAGE","status":"UPLOADED"}],"mediaUserErrors":[],"product":{"id":"gid://shopify/Product/9035571200218","title":"1-Db Goddess"}}},"extensions":{"cost":{"requestedQueryCost":20,"actualQueryCost":20,"throttleStatus":{"maximumAvailable":2000.0,"currentlyAvailable":1980,"restoreRate":100.0}}}}
But when I go to my product I see this error:
I can upload the file manually, just not through graphql.
I’ve included the image I’m trying to upload for reference.
It’s not too big, in either width x height or file size.
I am doing an integration with shopfy and I am running a dev site, does that have anything to do with the error?
Please help.
The product create media mutation is deprecated, could you try one of the supported mutations like product update productUpdate - GraphQL Admin
Also from your response, it doesn’t look like you are checking the userErrors that are returned from the mutation.
Thank you for your reply, tried the mutation and unfortunately I still see the same error on the product.
Here’s my mutation:
mutation productUpdate($media: [CreateMediaInput!]!, $product: ProductUpdateInput!) {
productUpdate(media: $media, product: $product) {
product {
id
media(first:10) {
nodes {
alt
mediaContentType
preview {
status
}
}
}
}
userErrors {
field
message
}
}
}
Got the response below form “productUpdate” mutation:
{
"data": {
"productUpdate": {
"product": {
"id": "gid://shopify/Product/9035571200218",
"media": {
"nodes": [
{
"alt": "",
"mediaContentType": "IMAGE",
"preview": {
"status": "UPLOADED"
}
}
]
}
},
"userErrors": []
}
},
"extensions": {
"cost": {
"requestedQueryCost": 20,
"actualQueryCost": 14,
"throttleStatus": {
"maximumAvailable": 2000.0,
"currentlyAvailable": 1986,
"restoreRate": 100.0
}
}
}
}
Well… this was on me.
I was using the google POST method first and then moved to the PUT method, but did not update my HTTP content to work with PUT.
Once I did that, everything worked fine.
Plus I moved to the new fileUpdate
mutation.
1 Like