Development discussions around Shopify APIs
Hello there,
I'm using Shopify's GraphQL API (Python SDK) to get products, their variants and meta-fields. I've tested my query on Postman and Shopify Admin API GraphiQL explorer and it seems to work just fine but when use python SDK I get the following error:
{"errors":[{"message":"Field 'contextualPricing' doesn't exist on type 'ProductVariant'","locations":[{"line":27,"column":15}],"path":["query","products","edges","node","variants","edges","node","contextualPricing"],"extensions":{"code":"undefinedField","typeName":"ProductVariant","fieldName":"contextualPricing"}}]}
Here the code snippet:
products_query = """{
products(first: 5, sortKey: ID) {
edges {
cursor
node {
id
handle
hasOnlyDefaultVariant
status
tags
title
totalInventory
vendor
metafields(first: 5) {
edges {
node {
id
key
namespace
value
}
}
}
variants(first: 5) {
edges {
node {
contextualPricing(context: {}) {
price {
amount
}
compareAtPrice {
amount
}
}
sku
}
}
}
}
}
}
}"""
shopify.ShopifyResource.activate_session(shopify_session)
result = shopify.GraphQL().execute(products_query)
shopify.ShopifyResource.clear_session()
Any Ideas?
Regards,
Alex.
Solved! Go to the solution
This is an accepted solution.
Hi @amatosc ,
I suspect you use an old API version. If you test it on 2021-10 it works.
Regards
Thomas
This is an accepted solution.
Hi @amatosc ,
I suspect you use an old API version. If you test it on 2021-10 it works.
Regards
Thomas
User | RANK |
---|---|
8 | |
7 | |
3 | |
3 | |
3 |
Connect your PayPal account to allow your customers to checkout using the PayPal gateway a...
ByYour online store speed can enhance your store’s discoverability, boost conversion rates a...
ByShopping is at our fingertips with mobile devices. Is your theme optimized to be user-frie...
By