Dedicated to the Hydrogen framework, headless commerce, and building custom storefronts using the Storefront API.
I'm trying to set up a post-purchase upsell.
I submit all required fields to the calculateChangeset function, but the request returns an "Invalid token" message. API_KEY and SECRET are correct. Also, the API key in the Chrome extension is equal to the API key in my extension .env. Are there any additional reasons why requests may be rejected?
Thank you.
Hi @mashkovtsev, I'm facing the same issue and don't have any information about this issue on the web, except for your post here... Did you figure out anything?
I had the same error, in my case it was the malformed "changes" parameter passed to the "calculateChangeset" shopify endopoint.
I was using an object, but the endpoint requires an Array of object, so instead of passing something like:
const changes = {
type: "add_variant",
variantID: 123456789,
quantity: 1,
discount: {
value: 15,
valueType: "percentage",
title: "15% off",
}
};
you should use:
const changes = [{
type: "add_variant",
variantID: 123456789,
quantity: 1,
discount: {
value: 15,
valueType: "percentage",
title: "15% off",
}
}];
and finally:
const result = await calculateChangeset({
changes: changes
});
Hope it helps! ^_^