发表帖子以Shopify API,导致400
我正在向 Shopify API 发出 POST 请求,将产品对象发送到“/cart/add.js”,但我不断收到 400 响应。我从表单中捕获的所有值都是正确的。所以我的对象的结构是错误的。该对象如下所示:
const items = {
products: [
{
quantity: quantity,
id: variantId,
properties: {
"I am a": document.getElementById('i-am-a').value,
"Company Name": document.getElementById('company-name').value,
"Email": document.getElementById('email-capture').value,
},
}
]
};
I am making a POST request to the Shopify API to send the product object to '/cart/add.js' but I keep getting a 400 response. All of the values I am capturing from the form are correct. So it is the structure of my object that is wrong. Here is what the object looks like:
const items = {
products: [
{
quantity: quantity,
id: variantId,
properties: {
"I am a": document.getElementById('i-am-a').value,
"Company Name": document.getElementById('company-name').value,
"Email": document.getElementById('email-capture').value,
},
}
]
};
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
必须在卡车API上找到这篇文章
https://shopify.dev/api/ajax/ajax/ajax/reference/cart 应该命名项目
Had to find this article on the Cart API
https://shopify.dev/api/ajax/reference/cart
the products array should be named items