对 Shopify API 进行 POST 生成 400

Making a POST to Shopify API resulting in 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,
    },
  }
]

};

不得不在购物车上找到这篇文章 API https://shopify.dev/api/ajax/reference/cart

const data = {
items: [
  {
    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,
    },
  }
]
};

产品数组应命名为 items