GraphQL:uploading Image and using imageURL with GraphQL gives "internal error" (ProductAppendImages)

Highlighted
New Member
4 0 0

using private app (python script) to upload images to a product from local files. 

 

Getting internal error when I want to use a URL from the uploaded image to assign to a product. 

----

 

uploading image using the stageUploadTargetGenerate, creates the object and returns a URL. 

 

 

create_img.jpg

the above step works :-)

 

but when i try to use the url to assign it to a product using:

image-append.jpg

 

I'm getting error:

 

int-error.jpg

 

Internal error. Looks like something went wrong on our end.\nRequest ID: 595103de-9f11-4bb7-b5bc-db3f5d8c1d30 (include this in support requests)

 

this is probably something every simple, but don't see it :-( 


Then I click on the url (not sure it you should be able to click on it and see the image, but.. I'm getting a "SIgnatureDoesNotMatch error from AWS. 

aws.jpg

 

so maybe I'm doing something wrong with encoding/decoding/escaping or its just something wrong at the shopify side.


Code is written in Python3, and can share that too, but think the mutations are probably more useful.

Any hints? Anybody?

 

0 Likes
Highlighted
Shopify Staff
Shopify Staff
1041 140 167

Hey @go4it,

 

You'll hit that error if you run a productAppendImages mutation before uploading the image. Try this flow:

 

1. Generate a signed URL

mutation {
  stagedUploadTargetGenerate(input: {resource:PRODUCT_IMAGE, filename: "hello.jpg", mimeType: "image/jpeg" }) {
    url
  }
}


2. Upload an image to the URL generated above. Here's how you can do it with Postman:
20-19-vxa2b-5u4x5.png

3. Attach the new image to a product:

mutation productAppendImages($input: ProductAppendImagesInput!) {
  productAppendImages(input: $input) {
    newImages {
      id
    }
    product {
      id
    }
    userErrors {
      field
      message
    }
  }
}

{
  "input": {
    "id": "gid://shopify/Product/<product id>",
    "images": [
      { "altText": "hello", "src": "<url from step 1>" }
    ]
  }
}


The SignatureDoesNotMatch error is to be expected - you wont be able to read the image.


Let me know how you go.

 

Notice; Out of office, replies will be delayed until my return. Thanks!
1 Like
Excursionist
17 0 7

Question. 

To upload and assign an image to a ProductVariant in GraphQL.

Can you go directly to the Variant? or do you have to follow the above pattern of:

  • StageUploadCreate
  • Upload the File
  • productAppendImages
  • productVariantUpdate

In REST you can do this in 1 call.

Cheers

John

 

0 Likes