Shopify Flow is an ecommerce automation platform that enables you to automate tasks and processes within your store and across your apps.
Hey guys!
I'm trying to use Shopify Flow to automatically update the variant cost and a few other variant level fields when triggered in Flow. I've developed the query I want, and have it running properly in a Google Script (Javascript with a Google wrapper), but when I attempt to move it over to Flow it breaks down. Here's what I have -
function pushToShopify() {
var headers = {
'X-Shopify-Access-Token': password,
}
let query = JSON.stringify({
query: 'mutation inventoryItemUpdate($id: ID!, $input: InventoryItemInput!) { inventoryItemUpdate(id: $id, input: $input) { inventoryItem { id unitCost { amount } } userErrors { message } } }',
"variables": {
"id": "gid://shopify/InventoryItem/49216882835776",
"input": {
"cost": 0.1,
"tracked": false,
"countryCodeOfOrigin": "US",
}
}
});
var options = {
method: 'POST',
headers: headers,
contentType: "application/json",
payload: query,
muteHttpExceptions: true
}
var url = "https://[my-store].myshopify.com/admin/api/2025-01/graphql.json";
Logger.log(url);
Logger.log(options);
var resp = UrlFetchApp.fetch(url, options);
Logger.log(resp)
let object = JSON.parse(resp.getContentText())
Logger.log(object)
return [JSON.parse(resp.getContentText()), resp.getHeaders()]
}
Here's the response I get in Google Script -
{"data":{"inventoryItemUpdate":{"inventoryItem":{"id":"gid://shopify/InventoryItem/49216882835776","unitCost":{"amount":"0.1"},"tracked":false,"countryCodeOfOrigin":"US"},"userErrors":[]}},"extensions":{"cost":{"requestedQueryCost":10,"actualQueryCost":10,"throttleStatus":{"maximumAvailable":2000.0,"currentlyAvailable":1990,"restoreRate":100.0}}}}
So I attempted to migrate this to Shopify Flow, using the Send HTTP request Action with the following details -
And this is the exception I receive -
{"status":400,"response_body":"Bad Request","verb":"POST","url":"https://core.sfe.shopifyinternal.com/admin/api/2025-01/graphql.json","request_body":"\"query\":\"mutation inventoryItemUpdate($id: ID!, $input: InventoryItemInput!) { inventoryItemUpdate(id: $id, input: $input) { inventoryItem { id unitCost { amount } tracked countryCodeOfOrigin} userErrors { message } } }\",\"variables\":{\"id\":\"gid://shopify/InventoryItem/49216882835776\",\"input\":{\"cost\":0.1,\"tracked\":false,\"countryCodeOfOrigin\":\"US\"}}"}
I cannot figure out what's going on. This works flawless in Google Script, but I always get a Bad Request exception whenever I attempt to run this in Flow. To note, I regularly run other HTTP requests in Flow such as the one in the screenshot below and so I have had some success with this before, but not sure what I'm doing wrong. Any ideas?
Is there a reason you're using Send HTTP request instead of Send Admin API request? The latter is more secure and less expensive. For reference, Flow currently uses Admin API version 2024-04.
Also:
Hey Community! As we jump into 2025, we want to give a big shout-out to all of you wh...
By JasonH Jan 7, 2025Hey Community! As the holiday season unfolds, we want to extend heartfelt thanks to a...
By JasonH Dec 6, 2024Dropshipping, a high-growth, $226 billion-dollar industry, remains a highly dynamic bus...
By JasonH Nov 27, 2024