Skip to main content
Solved

Cannot create a product, fetch products & categories via API

  • 13 June 2024
  • 1 reply
  • 45 views

Hello,

I am implementing the Klaviyo API into our shop, but I am encountering many obstacles along the way.

I attempted to create a product by following this example: https://developers.klaviyo.com/en/reference/create_catalog_item

However, I keep receiving this response: {"errors":[{"id":"d7881baa-2a71-47f3-8dbd-83bf61519408","status":400,"code":"invalid","title":"Invalid input.","detail":"A category in your relationship payload does not exist","source":{"pointer":"/data/relationships/categories/data/id"},"links":{},"meta":{}}]

I cannot determine the correct format for the category. The documentation uses "$custom:::$default:::SAMPLE-DATA-CATEGORY-APPAREL", but it does not explain what "SAMPLE-DATA-CATEGORY-APPAREL" actually is and where I should get it from. We have many products and categories imported. The categories have only numerical IDs. I tried, for example, "$custom:::$default:::1084243023", but I received the same response.

Then, I had the idea to fetch categories and see how the "id" looks there by using this example: https://developers.klaviyo.com/en/reference/get_catalog_categories. The response was: {"data":[],"links":{"self":"https://a.klaviyo.com/api/catalog-categories/","next":null,"prev":null}}

I also tried to fetch all products using this example: https://developers.klaviyo.com/en/reference/get_catalog_items The response was: {"data":[],"links":{"self":"https://a.klaviyo.com/api/catalog-items/","next":null,"prev":null}}

Can you please help me with this?

Thank you.

Lukas

1 reply

Userlevel 5
Badge +30

Hi @Evermart! If the Get Catalog Categories is returning null, that indicates they haven't been created correctly (or at all). You’ll need to create the categories first before linking them to a product.

 

Hope that helps! :)

Reply