GraphQL Api Inventory Bulk Quantities Adjustments in C#

Topic summary

A developer is experiencing issues with Shopify’s GraphQL API for bulk inventory quantity adjustments in C#. Despite receiving HTTP 200 responses, inventory updates aren’t reflecting on the Shopify site, and API responses return null.

Initial Setup:

  • Code processes items in batches of 100
  • Uses inventoryBulkAdjustQuantitiesAtLocation mutation
  • Receives successful status codes but no actual updates

Troubleshooting Suggestions Provided:

  • Verify access token has proper inventory update permissions
  • Confirm data formatting with valid inventory item IDs and location IDs
  • Check userErrors field in response (not just response.Errors) for application-specific errors
  • Ensure mutation name in deserialized response class matches API exactly
  • Test the mutation manually in Shopify GraphQL App to isolate issues

Current Status:

  • Developer confirmed permissions and data are correct
  • Now attempting alternative API: inventorySetOnHandQuantities (sets absolute values vs adjustments)
  • Latest issue: inventoryAdjustmentGroup response is null, but userErrors contains two null entries for field and message

The discussion remains open with unresolved null response issues.

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

Hi AdvancedModel,

From a quick look, the code you have posts seems okay. Here are a couple of things you can check:

  1. Permissions: Make sure the access token you are using has the right permissions to update the inventory.

  2. Data: Ensure the data you are sending in the invItemAdjustments variable is correctly formatted and contains valid inventory item IDs and location IDs.

  3. Error Handling: The response.Errors only contains GraphQL syntax errors. Shopify also returns user errors in the userErrors field in the response body which describes the application-specific errors. You are querying it, but not checking it. These are errors like missing permissions or invalid data.

  4. Location ID: You’ve mentioned <correct> in the locationId. Ensure you’re replacing this with a valid location ID.

Here’s how you can modify your code to handle userErrors:

if (response.Data?.InventoryBulkAdjustQuantitiesAtLocationMutation?.UserErrors?.Count > 0)
{
    // Handle user errors for this batch
    foreach (var error in response.Data.InventoryBulkAdjustQuantitiesAtLocationMutation.UserErrors)
    {
        _logger.LogError("User error from GraphQL API in field {0}: {1}", error.Field, error.Message);
    }
}
else
{
    InventoryBulkAdjustResponse inventoryLevels = response.Data;
    // Rest of your code
}

Note: The InventoryBulkAdjustQuantitiesAtLocationMutation should match the name you provide in your deserialized response class. If you’re still encountering issues, try running the same mutation query manually in the Shopify GraphiQL app to see if you get any additional errors there.

Hope this helps,