Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/magento/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Magento 2 Rest api:无法下订单。获取错误_Magento_Magento2 - Fatal编程技术网

Magento 2 Rest api:无法下订单。获取错误

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"

致命错误:未捕获的GuzzleHttp\Exception\ClientException:客户端错误:
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此代码运行良好。