Solved

Graphql inventoryBulkAdjustQuantityAtLocation error bad request

amer2737
Tourist
3 0 0

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
}
]
}
}' 
Accepted Solution (1)

tewe
Shopify Partner
244 46 102

This is an accepted solution.

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

• Was my reply helpful? Click Like to let me know!
• Was your question answered? Mark it as an Accepted Solution
• Check out our Price Updater App

View solution in original post

Replies 2 (2)

tewe
Shopify Partner
244 46 102

This is an accepted solution.

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

• Was my reply helpful? Click Like to let me know!
• Was your question answered? Mark it as an Accepted Solution
• Check out our Price Updater App

digitalDot
Visitor
1 0 1

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/***\"