jSon uploading product with weird filename

Hi,

I use a FileMaker database to organize products and images then upload to Shopify.

It works great, though there is one quirk. The filename goes up wonky on the upload.

But if I update the product with pretty much the same into, the update corrects the problem.

i.e. Upload (goes up wrong):

bacon-lip-balm_a64ccf5d-ee6c-4544-bbe8-5f8f37a12efe

Update (goes up correctly):

bacon-lip-balm

I’ve included the jSon lines (removing site info) for upload and update if that’s of use.

Anyone have an idea? Thanks!

ADD PRODUCT TO SHOPIFY:
{“data”:{“product”:{“barcode”:“”,“body_html”:“Prevent chapped lips with the mouthwatering flavor of bacon!
Every time you eat bacon don’t you wish you could taste that cured meat flavor all day long?
Well, now you can!
Just carry around a tube of this Bacon Lip Balm and you can keep your lips moist and meaty around the clock.
Each tube is 2-1/2" long with a twist bottom dispenser.”,“images”:[{“alt”:“Bacon Lip Balm”,“attachment”:“PICTURE, I WON’T INCLUDE BINARY!”,“filename”:“bacon-lip-balm.jpg”}],“metafields_global_description_tag”:“Bacon lip balm keeps your lips moist and tasting like bacon all day long! 2.5 inch tube with twist-bottom dispenser.”,“metafields_global_title_tag”:“Bacon Lip Balm | Archie McPhee”,“product_type”:“”,“title”:“Bacon Lip Balm”,“variants”:[{“alt”:“Bacon Lip Balm”,“cost”:“”,“price”:“”,“sku”:“AC11957”,“tracked”:“true”,“weight”:“”}],“vendor”:“Archie McPhee”}},“headers”:{“Content-Type”:“application/json”},“method”:“POST”,“url”:“URL BEING USED/products.json”}

UPDATE PRODUCT TO SHOPIFY:
{“data”:{“product”:{“barcode”:“”,“body_html”:“Prevent chapped lips with the mouthwatering flavor of bacon!
Every time you eat bacon don’t you wish you could taste that cured meat flavor all day long?
Well, now you can!
Just carry around a tube of this Bacon Lip Balm and you can keep your lips moist and meaty around the clock.
Each tube is 2-1/2" long with a twist bottom dispenser.”,“id”:7100942057560,“images”:[{“alt”:“Bacon Lip Balm”,“attachment”:“BINARY OF PICTURE”,“filename”:“bacon-lip-balm.jpg”}],“metafields_global_description_tag”:“Bacon lip balm keeps your lips moist and tasting like bacon all day long! 2.5 inch tube with twist-bottom dispenser.”,“metafields_global_title_tag”:“Bacon Lip Balm | Archie McPhee”,“product_type”:“”,“tags”:“”,“title”:“Bacon Lip Balm”,“variants”:[{“alt”:“Bacon Lip Balm”,“id”:“39932170764376”,“tracked”:“true”,“weight”:“”}],“vendor”:“Archie McPhee”}},“headers”:{“Content-Type”:“application/json”},“method”:“PUT”,“url”:“URL BEING USED/products/7100942057560.json”}

From my experience trying to upload images this is what I can tell you:

if the file exists with that filename already, then it will create a new file, start with the filename and then append a UUID to the end

Why does it create 2 files?

from using the API and trying to upload a file AND attach it to a product I have found that it is not possible without Shopify creating a

new file from the already uploaded file.

So as an example:

I use the API to upload an image to files. The file has the correct name. Next I try to use the API to attach the image to a product, BUT

there is no function that is capable of doing that. The function to update an image on a product does not add a new image, but only let’s

you change something about an existing image that is already attached to the product, so Shopify makes me use the ProductCreateMedia mutation

to add an image to a product, however, when I pass the Id of the already uploaded image, Shopify creates a new file, and since the file

already exists, the filename gets the appended UUID.

As an alternative I tried to use the ProductCreateMedia mutation to add an image from an external URL, but then there is no parameter in

which I can pass the filename and the file gets an even more random name, so my next attempt will be to see if I can then access the file

and actually rename it to the filename of the image.

To verify if what I am explaining is happening to your files, go to your files and see if you have a file that has the correct filename and see if

it is attached to the product before you use your update to correct the issue. My guess is that your update changes the attached image to

use the correctly named file, but then you also have a copy that is no longer attached and has the extended filename.

This has been an ongoing problem for me because the REST API image upload works great but it is constantly erroring out, so I am attempting

to use the GraphQL Admin API but am finding that although it consistently works, it does not have the same direct process for uploading and

attaching an image to a product.

Isn’t computer code a blast!