Hello,
When we try to follow the example “Get the first three product variants updated after the specified date” from the Shopify documentation: https://shopify.dev/api/admin-graphql/2022-01/queries/productVariants#examples-Get_the_first_three_product_variants_updated_after_the_specified_date
we receive the “Bad Request” error.
The request we try is:
curl -X POST https://your-development-store.myshopify.com/admin/api/2022-01/graphql.json -H 'Content-Type: application/json' -H 'X-Shopify-Access-Token: {access_token}' -d '{"query": "query { productVariants(first: 3, query: "updated_at:>2021-01-01") { edges { node { id title price updatedAt inventoryQuantity product { id title } } } } }"}'
of course with replaced {access_token} part and our website’s url.
When we modify the request a bit it then returns correct data:
curl -X POST https://your-development-store.myshopify.com/admin/api/2022-01/graphql.json -H 'Content-Type: application/graphql' -H 'X-Shopify-Access-Token: {access_token}' -d '{productVariants(first: 3, query: "updated_at:>2021-01-01") { edges { node { id title price updatedAt inventoryQuantity product { id title } } } } }'
Could you please check why the example from Shopify’s documentation doesn’t work?
We build an integration and part of our logic is to check whether a product with particular barcode already exists in Shopify before creating a new product, for this we use the following request which is based on the above example:
curl -X POST https://your-development-store.myshopify.com/admin/api/2022-01/graphql.json -H 'Content-Type: application/graphql' -H 'X-Shopify-Access-Token: {access_token}' -d '{productVariants(first: 10,query: "barcode:XXX") {edges {node {id sku barcode inventoryItem{id} product{id}}}}}'
It seemed to work fine until one day we realised some products are duplicated in Shopify. We found out that the above call works fine like in 90% of time but sometimes it returns data for some products but not all, even if the barcode is exactly the same. Is there some known bug related to the issue I described? Perhaps you can suggest a different api endpoint/request we should use to determine if a product with particular barcode already exists in Shopify?
Thanks,
Paul
