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.

I have a function in C# which takes an array of validly formatted objects and passes them to the GraphQL API, and I get status 200 as a response… However, nothing ever updates on the Shopify Site. And the response is always null.

Here is the code

int batchSize = 100;
string ShopifyGraphURL = _myShopifyUrl + "/admin/api/2023-07/graphql.json";
var graphQLClient = new GraphQLHttpClient(ShopifyGraphURL, new NewtonsoftJsonSerializer());
graphQLClient.HttpClient.DefaultRequestHeaders.Add("X-Shopify-Access-Token", this._accessToken);

            var batches = vplItems
    .Select((item, index) => new { Item = item, Index = index })
    .GroupBy(x => x.Index / batchSize)
    .Select(group => group.Select(x => x.Item).ToList())
    .ToList();

            foreach (var batch in batches)
            {
                
                var request = new GraphQLRequest
                {
                    Query = @"
                        mutation InventoryBulkAdjustQuantitiesAtLocationMutation($invItemAdjustments: [InventoryAdjustItemInput!]!) {
                          inventoryBulkAdjustQuantityAtLocation(inventoryItemAdjustments: $invItemAdjustments, locationId: ""gid://shopify/Location/

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,

  1. Permissions are correct

  2. Data is correct

  3. has been converted to a class that populates from the json

  4. yes, it was redacted before posting

5, I am now trying to use another API which allows me to set Quantities as absolute Values, inventorySetOnHandQuantities

Now the inventoryAdjustmentGroup response is null, but userErrors contains a response with two nulls for field and message