Updating Inventory with HTTP request via Flow

Hello,

I am attempting to use flow to send a HTTP request and it works fine with the Shopify GraphiQL App, but when I put it into the request it succeeds but doesn’t adjust the stock:

This is my code:

{"query":"mutation inventoryAdjustQuantities($input:InventoryAdjustQuantitiesInput!){ inventoryAdjustQuantities(input:$input){inventoryAdjustmentGroup{createdAt reason referenceDocumentUri changes {name delta}} userErrors {field message}}}","variables":{"input":{"reason":"fspc","name":"available","changes":[{"delta":-1,"inventoryItemId":"gid://shopify/InventoryItem/41586104598727","locationId":"gid://shopify/Location/13703824"}]}}}

This is the http request:

Any help would be appreciated thank you.

1 Like

Can you share the response you’re getting back?

Hello, This is the response:

It succeeds but nothing happens

1 Like

Possible that there are userErrors coming back but I don’t believe flow is going to show you the response - it just looks at the response code which will come back as 200 even if there are userErrors.

May want to log output of the query, url, and headers from the http request, and then run that manually via curl and see if you get an error.

After some changes I’ve gotten it to this:

curl -X POST https://xxxxxxx.myshopify.com/admin/api/2024-01/graphql.json -H 'Content-Type: application/json' -H 'X-Shopify-Access-Token: xxxxxxxxxxxx' -d "{\"query\": \"mutation inventoryAdjustQuantities(\$input: InventoryAdjustQuantitiesInput!) { inventoryAdjustQuantities(input: \$input) { inventoryAdjustmentGroup { reason changes { name delta } } userErrors { field message } } }\", \"variables\": { \"input\": { \"reason\": \"fspc\", \"changes\": [ { \"delta\": 100, \"inventoryItemId\": \"gid://shopify/InventoryItem/41586104598727\", \"locationId\": \"gid://shopify/Location/13703824\" } ] }}"

And my errors are:

{“errors”:{“query”:“Required parameter missing or invalid”}}curl: (6) Could not resolve host: application
curl: (3) URL rejected: Bad hostname

I changed to use the REST API:
URL: https://xxxxx.myshopify.com/admin/api/2024-01/inventory_levels/adjust.json

Body: {“location_id”:13703824,“inventory_item_id”:41586104598727,“available_adjustment”:-1}

1 Like