Updating Inventory with HTTP request via Flow

Solved

Updating Inventory with HTTP request via Flow

KathyRR
Tourist
7 1 3

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:

Untitled.png

 

Any help would be appreciated thank you.

Accepted Solution (1)

KathyRR
Tourist
7 1 3

This is an accepted solution.

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}

View solution in original post

Replies 5 (5)

Kalen_Jordan
Shopify Partner
737 34 128

Can you share the response you're getting back?

KathyRR
Tourist
7 1 3

Hello, This is the response:

 

Untitled.png

 

It succeeds but nothing happens

 

Kalen_Jordan
Shopify Partner
737 34 128

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.

KathyRR
Tourist
7 1 3

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
Untitled.png

KathyRR
Tourist
7 1 3

This is an accepted solution.

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}