Php Bigcommerce购物车422:缺少必填字段错误

Php Bigcommerce购物车422:缺少必填字段错误,php,laravel,api,cart,bigcommerce,Php,Laravel,Api,Cart,Bigcommerce,我正在使用Laravel来使用BigCommerceV3API 我已经成功地创建了一个新的购物车。但是,当尝试向其中添加一个项目时,我不断得到一个422:Missing required fields错误 我用这样的口吻提出我的要求: return json_decode($this->client->getRestClient() ->post('carts/'.$cartId.'/items?include=line_items.physical_i

我正在使用Laravel来使用BigCommerceV3API

我已经成功地创建了一个新的购物车。但是,当尝试向其中添加一个项目时,我不断得到一个
422:Missing required fields
错误

我用这样的口吻提出我的要求:

return json_decode($this->client->getRestClient()
            ->post('carts/'.$cartId.'/items?include=line_items.physical_items.options', [
                'Accept' => 'application/json',
                'json' => [
                    'line_items' => [
                        'product_id' => 86,
                        'quantity' => 1
                    ],
                ],
            ])
            ->getBody())
        ->data;
[
    {
        "product_id":86,
        "quantity":1
    }
]
我试图添加的产品没有选项或修改器,因此我不明白我的请求可能有什么问题。根据政府的说法,这应该是所有需要的

有人知道会出什么问题吗?我试着联系支持人员,但没有结果。
提前谢谢

行项目
是一个对象数组。尝试将产品数据包装到对象中

像这样:

'line_items' => [
  {
    'quantity' => 1,
    'product_id' => 86
  }
]

line\u items
是一个对象数组。尝试将产品数据包装到对象中

像这样:

'line_items' => [
  {
    'quantity' => 1,
    'product_id' => 86
  }
]

您的
行\u项
字段需要有一个对象数组,如下所示:

return json_decode($this->client->getRestClient()
            ->post('carts/'.$cartId.'/items?include=line_items.physical_items.options', [
                'Accept' => 'application/json',
                'json' => [
                    'line_items' => [
                        'product_id' => 86,
                        'quantity' => 1
                    ],
                ],
            ])
            ->getBody())
        ->data;
[
    {
        "product_id":86,
        "quantity":1
    }
]

您的
行\u项
字段需要有一个对象数组,如下所示:

return json_decode($this->client->getRestClient()
            ->post('carts/'.$cartId.'/items?include=line_items.physical_items.options', [
                'Accept' => 'application/json',
                'json' => [
                    'line_items' => [
                        'product_id' => 86,
                        'quantity' => 1
                    ],
                ],
            ])
            ->getBody())
        ->data;
[
    {
        "product_id":86,
        "quantity":1
    }
]

让它成为```行项目=>[[['产品id'=>86,'数量'=>1,],],``就成功了。谢谢让它成为```行项目=>[[['产品id'=>86,'数量'=>1,],],``就成功了。谢谢示例显示了一个api键:
X-Auth-Token:{access\u Token}
您是否忘记添加它?示例显示了一个api键:
X-Auth-Token:{access\u Token}
您是否忘记添加它?