I’ve got process that runs every 3 hours, it will take all the products we have and send over current inventory numbers in cases where it has changed. It uses this api endpoint:
https://developers.klaviyo.com/en/reference/update_catalog_variant
I do actually record requests and responses for all the things. Every once in a while (maybe once a week?) we’ll see the api respond with an error about patch bodies being required. It failed earlier this morning, about 20 minutes ago.
I’m fairly certain the code that builds the payload is correct as there are ~1200 successful requests so far today, and only 1 failure. Looking at the previous runs, even the same catalogue variant that failed worked 3x so far today… with the same payload (different inventory , only one of them raises a 400 error.
Very strange… anyone seen this before? I’m thinking I might just ignore the error and continue processing if I see it. Right now a 400 error like that bails the run and it trips up our monitoring which is a bit annoying.
--
Sample request:
PATCH /api/catalog-variants/$custom:::$default:::000001213873_en-ca?
data:
{
"data": {
"id": "$custom:::$default:::000001213873_en-ca",
"type": "catalog-variant",
"attributes": {
"sku": 1213873,
"url": "https://epicure.com/en-ca/product/gingerbread-mix",
"price": 13,
"title": "Gingerbread Mix (Pack of 2)",
"published": true,
"description": "<p>Gingerbread Mix features the traditional aromas of ginger, cinnamon, and clove come together to make a classic gingerbread blend. </p>\n<p>Prep tips:</p>\n<ul>\n <li>No oven is needed for this 5-minute recipe! Add oil, molasses, and Gingerbread Mix to a silicone round cake pan, and microwave on high for 4–5 minutes! This hassle-free recipe is sure to bring on the holiday cheer. </li>\n <li>Use the mix to make cakes or muffins, or try it as a base for waffles and pancakes! </li>\n <li>One bag serves up to 12 people for only $0.56 a serving! </li>\n</ul>\n<p>INGREDIENTS</p>\n<p>Baking soda, Chickpea flour, Cinnamon, Clove, Ginger, Organic cane sugar, Rice flour, Sea salt.</p>",
"image_full_url": "https://asset-delivery.epicure.com/4f365e04-333c-00ab-a1e0-d5cc0e128aa9/b8678db4-bbca-4472-9ebe-65f3fa42412b/Gingerbread%20Mix%20CA.jpg",
"inventory_policy": 1,
"inventory_quantity": 3294
}
},
"time": 1725991324
}
Error response (encountered at 2024-09-10 11:02:04.107517 -07:00):
{
"status": 400,
"context": {
"errors": :
{
"id": "eaf7e80d-d28e-4b1e-a6ab-3ead510075dd",
"code": "invalid",
"meta": {},
"links": {},
"title": "Invalid input.",
"detail": "Request bodies are required for PATCH requests.",
"source": {
"pointer": "/data"
},
"status": 400
}
]
},
"message": " 3rdparty] Klaviyo] Bad StatusCode: 400"
}
The same payload (more or less, only inventory changes) was sent at these timestamps and was successful:
2024-09-10 09:01:46.793186 -07:00
2024-09-10 07:01:50.679547 -07:00
2024-09-10 01:00:50.131682 -07:00
Request:
{
"data": {
"id": "$custom:::$default:::000001213873_en-ca",
"type": "catalog-variant",
"attributes": {
"sku": 1213873,
"url": "https://epicure.com/en-ca/product/gingerbread-mix",
"price": 13,
"title": "Gingerbread Mix (Pack of 2)",
"published": true,
"description": "<p>Gingerbread Mix features the traditional aromas of ginger, cinnamon, and clove come together to make a classic gingerbread blend. </p>\n<p>Prep tips:</p>\n<ul>\n <li>No oven is needed for this 5-minute recipe! Add oil, molasses, and Gingerbread Mix to a silicone round cake pan, and microwave on high for 4–5 minutes! This hassle-free recipe is sure to bring on the holiday cheer. </li>\n <li>Use the mix to make cakes or muffins, or try it as a base for waffles and pancakes! </li>\n <li>One bag serves up to 12 people for only $0.56 a serving! </li>\n</ul>\n<p>INGREDIENTS</p>\n<p>Baking soda, Chickpea flour, Cinnamon, Clove, Ginger, Organic cane sugar, Rice flour, Sea salt.</p>",
"image_full_url": "https://asset-delivery.epicure.com/4f365e04-333c-00ab-a1e0-d5cc0e128aa9/b8678db4-bbca-4472-9ebe-65f3fa42412b/Gingerbread%20Mix%20CA.jpg",
"inventory_policy": 1,
"inventory_quantity": 3300
}
},
"time": 1725984107
}
{
"data": {
"id": "$custom:::$default:::000001213873_en-ca",
"type": "catalog-variant",
"links": {
"self": "https://a.klaviyo.com/api/catalog-variants/$custom:::$default:::000001213873_en-ca/"
},
"attributes": {
"sku": 1213873,
"url": "https://epicure.com/en-ca/product/gingerbread-mix",
"price": 13,
"title": "Gingerbread Mix (Pack of 2)",
"images": 2],
"created": "2024-09-04T16:03:32.842000+00:00",
"updated": "2024-09-10T16:01:46.655000+00:00",
"published": true,
"description": "<p>Gingerbread Mix features the traditional aromas of ginger, cinnamon, and clove come together to make a classic gingerbread blend. </p>\n<p>Prep tips:</p>\n<ul>\n <li>No oven is needed for this 5-minute recipe! Add oil, molasses, and Gingerbread Mix to a silicone round cake pan, and microwave on high for 4–5 minutes! This hassle-free recipe is sure to bring on the holiday cheer. </li>\n <li>Use the mix to make cakes or muffins, or try it as a base for waffles and pancakes! </li>\n <li>One bag serves up to 12 people for only $0.56 a serving! </li>\n</ul>\n<p>INGREDIENTS</p>\n<p>Baking soda, Chickpea flour, Cinnamon, Clove, Ginger, Organic cane sugar, Rice flour, Sea salt.</p>",
"external_id": "000001213873_en-ca",
"image_full_url": "https://asset-delivery.epicure.com/4f365e04-333c-00ab-a1e0-d5cc0e128aa9/b8678db4-bbca-4472-9ebe-65f3fa42412b/Gingerbread%20Mix%20CA.jpg",
"custom_metadata": {},
"inventory_policy": 1,
"inventory_quantity": 3300,
"image_thumbnail_url": ""
},
"relationships": {
"item": {
"links": {
"self": "https://a.klaviyo.com/api/catalog-variants/$custom:::$default:::000001213873_en-ca/relationships/item/",
"related": "https://a.klaviyo.com/api/catalog-variants/$custom:::$default:::000001213873_en-ca/item/"
}
}
}
},
"links": {
"self": "https://a.klaviyo.com/api/catalog-variants/$custom:::$default:::000001213873_en-ca"
}
}