Graphql inventoryBulkAdjustQuantityAtLocation error bad request

I used the same example in the documentation and I check from the API access in inventory but I just get “Bad Request”

curl -X POST \
https://store.myshopify.com/admin/api/2022-01/graphql.json \
-H 'Content-Type: application/json' \
-H 'X-Shopify-Access-Token: ***' \
-d '{
"query": "mutation InventoryBulkAdjustQuantitiesAtLocationMutation( $inventoryItemAdjustments: [InventoryAdjustItemInput!]! ) { inventoryBulkAdjustQuantityAtLocation( inventoryItemAdjustments: $inventoryItemAdjustments, locationId: "gid://shopify/Location/***" ) { inventoryLevels { id available incoming item { id sku } location { id name } } } }",
"variables": {
"inventoryItemAdjustments": [
{
"inventoryItemId": "gid://shopify/InventoryItem/43536922804422",
"availableDelta": 3
},
{
"inventoryItemId": "gid://shopify/InventoryItem/13536921804422",
"availableDelta": 13
}
]
}
}'

Hi @amer2737 ,

“Bad request” - there are multiple reasons for this. My first guess would be that your access token is incorrect or you do not have the access scope for write_inventory.

At least the “bad request” does not says anything whether your graphql statement is correct or not.

Regards
Thomas

1 Like

We had the same problem, the fix is to escape the quote “” characters in the locationId parameters. Otherwise the json is malformed and thus it return Bad Request.

Just change

locationId: "gid://shopify/Location/***" 

to

locationId: \"gid://shopify/Location/***\"
1 Like