Inventory update please help

Topic summary

A developer is encountering errors when attempting to update inventory levels using Shopify’s GraphQL API with the inventoryAdjustQuantity mutation.

The Issue:

  • The code uses Python with the requests library to call the Fulfillment API
  • Error messages indicate field validation problems: inventoryItemId, locationId, and inventoryLevelId are reported as “not defined on InventoryAdjustQuantityInput”
  • The mutation expects certain field names or structure that don’t match what’s being provided

Technical Details:

  • Using API version 2024-01
  • Attempting to adjust inventory by +1 unit
  • The error response shows the provided values (inventoryItemId: “37106128519331”, locationId: “77564969224”, availableDelta: 1) are not being accepted

Current Status:
The discussion remains unresolved with no responses yet. The developer needs guidance on correct field names, input structure, or potential API version compatibility issues for the inventory adjustment mutation.

Summarized with AI on November 11. AI used: claude-sonnet-4-5-20250929.

hi eveyone,

please respond

I have used this code to update inventory level

here is the code

import requests

Your Shopify store URL and access token

shop_url = “XXXXXXXXXXX.myshopify.com
access_token = “XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX”

The GraphQL endpoint

graphql_url = f"https://{shop_url}/admin/api/2024-01/graphql.json"

The GraphQL mutation for updating inventory quantity

mutation = “”"
mutation inventoryAdjustQuantity($input: InventoryAdjustQuantityInput!) {
inventoryAdjustQuantity(input: $input) {
inventoryLevel {
id
available
}
userErrors {
field
message
}
}
}
“”"

Variables for the mutation

variables = {
“input”: {
“inventoryItemId”: “37106128519331”,
“locationId”: “77564969224”,
“availableDelta”: +1 # Adjust by this amount, e.g., +5 to increase, -5 to decrease
}
}

Headers including the access token and indicating JSON content

headers = {
“X-Shopify-Access-Token”: access_token,
“Content-Type”: “application/json”
}

Performing the POST request with the mutation and variables

response = requests.post(graphql_url, json={“query”: mutation, “variables”: variables}, headers=headers)

Checking the response

if response.status_code == 200:

Parsing the JSON response

json_response = response.json()
print(json_response)
else:
print(f"Failed to update inventory: {response.status_code}")

but when i run the code the code it gives me the below error message

{‘errors’: [{‘message’: ‘Variable $input of type InventoryAdjustQuantityInput! was provided invalid value for inventoryItemId (Field is not defined on InventoryAdjustQuantityInput), locationId (Field is not defined on InventoryAdjustQuantityInput), inventoryLevelId (Expected value to not be null)’, ‘locations’: [{‘line’: 2, ‘column’: 34}], ‘extensions’: {‘value’: {‘inventoryItemId’: ‘37106128519331’, ‘locationId’: ‘77564969224’, ‘availableDelta’: 1}, ‘problems’: [{‘path’: [‘inventoryItemId’], ‘explanation’: ‘Field is not defined on InventoryAdjustQuantityInput’}, {‘path’: [‘locationId’], ‘explanation’: ‘Field is not defined on InventoryAdjustQuantityInput’}, {‘path’: [‘inventoryLevelId’], ‘explanation’: ‘Expected value to not be null’}]}}]}