Hello Community,
I am working on a Python application that uses the Shopify GraphQL API to create new products and update their inventories. I have successfully managed to create new products and even update their inventories. However, I am encountering an issue where the inventory is not going to the correct location, despite the API call being successful.
# ... (Imports and other setups)
# Headers for the API
headers = {'X-Shopify-Access-Token': 'REDACTED', 'Content-Type': 'application/json'}
# GraphQL query to fetch existing locations
location_query = '''
{
locations(first: 5) {
edges {
node {
id
name
}
}
}
}
'''
# ... (Code to execute the above query and extract location ID)
# GraphQL mutation to update inventory
inventory_mutation = '''
mutation inventoryAdjustQuantity($inventoryLevelId: ID!, $quantity: Int!) {
inventoryAdjustQuantity(input: {inventoryLevelId: $inventoryLevelId, availableDelta: $quantity}) {
userErrors {
field
message
}
inventoryLevel {
id
available
}
}
}
'''
# Variables for the mutation
variables = {
'inventoryLevelId': 'gid://shopify/InventoryLevel/REDACTED',
'quantity': 20
}
# ... (Code to execute the above mutation)
Debugging Information:1. The location ID is correctly identified and used in the API call.
- The API call for inventory update is successful, and I get a proper response with no errors.
- I’ve double-checked the Shopify Admin, and the location settings seem to be correct.
Despite these, the inventory doesn’t seem to update to the correct location. Am I missing something here? Any help or pointers would be appreciated!
Thank you!