Im doing the following mutations to create a new product and link an image to it:
1- UPLOAD IMAGE TO SHOPIFY:
using the following mutation:
mutation stagedUploadsCreate($input: [StagedUploadInput!]!) {{
stagedUploadsCreate(input: $input) {{
stagedTargets {{
resourceUrl}}}}}}
input:
img = {
“input”: {
“filename”: “cavalo.jpg”,
“httpMethod”: “POST”,
“mimeType”: “image/jpg”,
“resource”: “IMAGE”
}}
2-ASSIGN IT TO A PRODUCT:
using the following mutation:
mutation productCreateMedia($media: [CreateMediaInput!]!, $productId: ID!) {{
productCreateMedia(media: $media, productId: $productId) {{
media {{
alt
id
mediaErrors{{
code
details
message
}}
mediaWarnings{{
code
message
}}
status
}}
mediaUserErrors {{
code
field
message
}}
product {{
handle
id
}}
userErrors {{
field
message
}}
}}
}}
input:
prodImg = {
“media”: {
“alt”: “garrafa img”,
“mediaContentType”: “IMAGE”,
“originalSource”: “https://shopify-staged-uploads.storage.googleapis.com/tmp/87055565100/products/67076b1a-02ae-4240-9f19-d5b125de1b51/cavalo.jpg” (this is the url I get as a response from uploading the img)
},
“productId”: “gid://shopify/Product/9172567130412” (this id the ID i got after creating my product)
}
I get no errors as a response from productCreateMedia: (200, {‘data’: {‘productCreateMedia’: {‘media’: [{‘alt’: ‘garrafa img’, ‘id’: ‘gid://shopify/MediaImage/37661322740012’, ‘mediaErrors’: , ‘mediaWarnings’: , ‘status’: ‘UPLOADED’}], ‘mediaUserErrors’: , ‘product’: {‘handle’: ‘jaqueta-30’, ‘id’: ‘gid://shopify/Product/9172567130412’}, ‘userErrors’: }}
However, when I access the product in shopify, I get Media Processing Failed error, how to fix it?