Have your say in Community Polls: What was/is your greatest motivation to start your own business?
Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Where can i get the file_reference for my images?

Where can i get the file_reference for my images?

Frederik4U
Visitor
2 0 5

We want to mange our metafields via a inventory management software. But when trying to upload a file_reference type, the connector gives back an error.

The Shopify server responded with status 422 and the following error: "value => must be a file reference string.

 

So i need somthing like this: gid://shopify/ MediaImage/123.

But where can i get the vaule to my image? I can only see the URL.

Thanks for Help

Replies 3 (3)

SozeArafat
Shopify Partner
9 0 3

Up ?

thinkcloud
Shopify Partner
8 0 0

umut-dev
Shopify Partner
3 0 1

You can use the following GraphQL query:

{
  files(first: 5, query: "filename:'yourfilename'" ) {
    edges {
      node {
        alt
        id
      }
    }
  }
}

But this query returns multiple files if they have similar names. Unfortunately there is no query parameter like a url or something.

https://shopify.dev/docs/api/admin-graphql/2024-01/queries/files

You can click on Show filters under the query argument to see the options.