Hi, we’re trying to subscribe users to BiS (Back in stock) via API, however, it’s not working.
We have 100+ custom catalog sources, so our code specifies which catalog and variant to match. The variable “studio” matches the correct catalog, in this case “Example” will match catalog https://www.klaviyo.com/catalog/sources/31134
input:
email: example@website.com
variant: 12345
platform: api
a: ABCDE
studio: Example
code:
const url = "https://a.klaviyo.com/onsite/components/back-in-stock/subscribe";
const studioToId = {
"Example": "31134",
"Example1": "31135",
"Example2": "31136",
// Continue list here
};
const id = studioToId[inputData.studio];
const data = new URLSearchParams({
a: inputData.a,
email: inputData.email,
variant: `$custom:::${id}:::${inputData.variant}`,
platform: inputData.platform
}).toString();
fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/x-www-form-urlencoded"
},
body: data
})
.then(response => response.json())
.then(data => {
console.log(data);
callback(null, data);
})
.catch((error) => {
console.error('Error:', error);
callback(error);
});
My hint is that the issue is in how we format $custom:::${id}:::${inputData.variant}
but I have limited knowledge here.
Any help?