Skip to main content

My fetch request looks like this

fetch(`https://a.klaviyo.com/api/v1/catalog/subscribe`, {
method: "POST",
headers: { "Content-Type": "application/x-www-form-urlencoded" },
body: new URLSearchParams({
a: process.env.NEXT_PUBLIC_KLAVIYO_KEY,
email: email,
variant: properties.variantId,
platform: 'shopify'
})
})

but the issue is that my shopify variant Ids are alphanumeric and this endpoint is requiring the integer ID that comes from my klaviyo catalog, and I’m a bit stuck on how to get this working properly.

 

Any info would be great, thanks!

Hi there @logansparlin

 

Welcome to the Community! Thanks for sharing your question with us! 

 

Unfortunately, the headless Shopify theme is not listed as a supported theme in Shopify for back in stock and the Klaviyo team therefore can’t help you troubleshoot this issue. However, I would reach out to one of our awesome Klaviyo partners who would love to help get this set up for you! 

 

Thanks for participating in the Community!

-Taylor 


Hi Taylor, thanks for the response! I’ll reach out to one of the Klaviyo partners and see what I can figure out. Happy to be a part of the community!


Solved my own problem, turns out I just had to decode the alphanumeric variant ID coming from the Shopify GraphQL API using the following code so that the variant Id is the correct format for the API

Buffer(variantId, 'base64').toString('binary').replace(/\D+/g, '')

 


Reply