# Updating an orders line items gives a 400 error

**URL:** <https://developer-forum.veeqo.com/t/updating-an-orders-line-items-gives-a-400-error/244>\
**Category:** API Queries (How To)\
**Created:** [July 22, 2020, 9:22am UTC](https://developer-forum.veeqo.com/t/updating-an-orders-line-items-gives-a-400-error/244 "2020-07-22T09:22:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![robtotm](https://avatars.discourse-cdn.com/v4/letter/r/FF9900/32.png) [@robtotm](https://developer-forum.veeqo.com/u/robtotm)\
**Post date:** [July 22, 2020, 9:22am UTC](https://developer-forum.veeqo.com/t/updating-an-orders-line-items-gives-a-400-error/244/1 "2020-07-22T09:22:43Z")

</div>

Hi,

I’m currently trying to update the quantity of an order using the following PHP method. This causes a 400 error. Where am I going wrong? The PHP variables all have values so I figured all the required fields are complete.

I’ve tried to just view an order using similar and it works so it’s correctly identifying the order, it’s just not updating it.

```
$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, "https://api.veeqo.com/orders/$order_id");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HEADER, FALSE);

curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");

curl_setopt($ch, CURLOPT_POSTFIELDS, "{
  \"order\": {
    \"line_items_attributes\": [
      {
        \"sellable_id\": $product_id,
        \"price_per_unit\": $product_price,
        \"quantity\": 10,
      }
    ]
  }
}");

curl_setopt($ch, CURLOPT_HTTPHEADER, array(
  "Content-Type: application/json",
  "x-api-key: 123"
));

$response = curl_exec($ch);
curl_close($ch);

var_dump($response);

```

---

<div class="post-metadata">

**Author:** ![calvin](https://yyz1.discourse-cdn.com/flex033/user_avatar/developer-forum.veeqo.com/calvin/32/66_2.png) [@calvin](https://developer-forum.veeqo.com/u/calvin)\
**Post date:** [July 23, 2020, 1:36pm UTC](https://developer-forum.veeqo.com/t/updating-an-orders-line-items-gives-a-400-error/244/2 "2020-07-23T13:36:18Z")

</div>

Hey @robtotm, in the case of a 400 Bad Request you should receive a JSON response containing the errors information (in the `error_messages` array). Could you please confirm the response body that you receive?

---

<div class="post-metadata">

**Author:** ![robtotm](https://avatars.discourse-cdn.com/v4/letter/r/FF9900/32.png) [@robtotm](https://developer-forum.veeqo.com/u/robtotm)\
**Post date:** [July 27, 2020, 1:16pm UTC](https://developer-forum.veeqo.com/t/updating-an-orders-line-items-gives-a-400-error/244/3 "2020-07-27T13:16:29Z")

</div>

Hi, the errors weren’t very descriptive so it didn’t really point me in the right direction. I figured it out in the end though… I just had to add more detail to the order and create a new channel (as it won’t work with our Woocommerce feed):

```
  $split_order = [
    "order" => [
      "channel_id" => 65460,
      "customer_id" => $customer_id,
      "deliver_to_id" => $deliver_to_id,
      "delivery_method_id" => $delivery_method_id,
      "payment_attributes" => array(
        "payment_type" => $payment_type
      ),
    ]
  ];
```
