Shopify Flow is an ecommerce automation platform that enables you to automate tasks and processes within your store and across your apps.
Hi everyone,
As title says, I can easily POST changing inventory level through REST API (/inventory_levels/set.json) using Postman, but when it spits out error 400 Required parameter missing or invalid when running on Flow.
In Postman:
{ "location_id":84988625182, "inventory_item_id":47947386061086, "available":41 }
I originally used liquid to insert dynamic data:
{% assign inventory = lineItemsForeachitem.variant.inventoryQuantity|plus:1%} { "location_id":84988625182, "inventory_item_id":{{lineItemsForeachitem.variant.inventoryItem.id|split:"/"|last}}, "available":{{inventory}} }
(note that this HTTP request is placed after for loop)
And here's the error I received from Flow:
{"status":400,"response_body":"{\"errors\":{\"inventory_item_id\":\"Required parameter missing or invalid\"}}","verb":"POST","url":"https://core.sfe.shopifyinternal.com/admin/api/2024-01/inventory_levels/set.json","request_body":"\n{\"location_id\":84988625182,\"inventory_item_id\":47947386061086,\"available\":41}"}
Which is funny because that "inventory_item_id" is exactly the same as the one I sent from Postman.
I also tried not using any liquid when sending the HTTP request from flow, but it still spits out the same error.
What am I doing wrong here?
Solved! Go to the solution
This is an accepted solution.
Hey Drsw,
Is your Content-Type header set to application/json?
Hi Drsw,
Looking at your error, it looks like your request is prefixed with a "\n", likely from the "assign" line if your liquid adding a newline. Replacing {% %} with {%- -%} will remove newlines when evaluating Liquid.
Try this:
{%- assign inventory = lineItemsForeachitem.variant.inventoryQuantity|plus:1 -%} { "location_id":84988625182, "inventory_item_id":{{lineItemsForeachitem.variant.inventoryItem.id|split:"/"|last}}, "available":{{inventory}} }
Hope that helps!
Hi @DaveMcV
Unfortunately that didn't help.
I also tried going straight from `Order Fulfilled` to `Send HTTP Request` with static body like this:
{"location_id":84988625182,"inventory_item_id":47947386061086,"available":41}
But it still gives the same error:
{"status":400,"response_body":"{\"errors\":{\"inventory_item_id\":\"Required parameter missing or invalid\"}}","verb":"POST","url":"https://core.sfe.shopifyinternal.com/admin/api/2024-01/inventory_levels/set.json","request_body":"{\"location_id\":84988625182,\"inventory_item_id\":47947386061086,\"available\":41}"}
I also tried wrapping the location and inventory_item's id with double quote, that also didn't help.
I double-checked my token but it's correct; Postman can send the same payload with the same token.
Is there anything else I missed?
This is an accepted solution.
Hey Drsw,
Is your Content-Type header set to application/json?
Awesome! Glad it's working. It happens to all of us 🙂
Thanks to everyone who participated in our AMA with 2H Media: Marketing Your Shopify St...
By Jacqui Sep 6, 2024The Hydrogen Visual Editor is now available to merchants in Shopify Editions | Summer '...
By JasonH Sep 2, 2024Note: Customizing your CSS requires some familiarity with CSS and HTML. Before you cust...
By JasonH Aug 12, 2024