Magento 2 Rest api:无法下订单。获取错误
致命错误:未捕获的GuzzleHttp\Exception\ClientException:客户端错误:Magento 2 Rest api:无法下订单。获取错误,magento,magento2,Magento,Magento2,致命错误:未捕获的GuzzleHttp\Exception\ClientException:客户端错误:PUThttp://magento.localhost.com/rest/V1/carts/4/order导致400错误请求响应:{“消息”:“请指定装运方法”。} 我的代码: $shipBill = '{ "addressInformation": { "shipping_address": { "id": 60, "customer_id": 1, "region"
PUThttp://magento.localhost.com/rest/V1/carts/4/order
导致400错误请求
响应:{“消息”:“请指定装运方法”。}
我的代码:
$shipBill = '{
"addressInformation": {
"shipping_address": {
"id": 60,
"customer_id": 1,
"region": "Arkansas",
"region_id": 5,
"country_id": "US",
"street": [
"Whitefield,New York"
],
"company": "IBM",
"telephone": "94354545",
"postcode": "234533",
"city": "New York",
"firstname": "test",
"lastname": "test",
"prefix": "address_",
"region_code": "AR"
},
"billing_address": {
"id": 60,
"customer_id": 1,
"region": "Arkansas",
"region_id": 5,
"country_id": "US",
"street": ["Whitefield,New York"],
"company": "IBM",
"telephone": "94354545",
"postcode": "234533",
"city": "New York",
"firstname": "test",
"lastname": "test",
"prefix": "address_",
"region_code": "AR"
},
"shipping_method_code": "flatrate",
"shipping_carrier_code": "flatrate"
}
}';
$checkout = $magento->createShippingAndBilling($quoteId, $shipBill)->getInArray();
$payment = '
{
"paymentMethod": {
"method": "checkmo"
}
}';
$order = $magento->orderCreate($quoteId, $payment)->getInArray();
我已经通过RESTAPI在购物车上添加了项目。只有当我试图下订单时,一切都正常。我发现了这个错误。我自己解决了。谢谢:)请分享问题是什么,其他有类似问题的人可以发现它有帮助@DmitriPortenko此代码运行良好。