# Error while updating product variant stock quantity

**URL:** <https://developer-forum.veeqo.com/t/error-while-updating-product-variant-stock-quantity/29>\
**Category:** API Queries (How To)\
**Created:** [August 3, 2017, 9:42am UTC](https://developer-forum.veeqo.com/t/error-while-updating-product-variant-stock-quantity/29 "2017-08-03T09:42:12Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andriy](https://yyz1.discourse-cdn.com/flex033/user_avatar/developer-forum.veeqo.com/andriy/32/28_2.png) [@Andriy](https://developer-forum.veeqo.com/u/Andriy)\
**Post date:** [August 3, 2017, 9:42am UTC](https://developer-forum.veeqo.com/t/error-while-updating-product-variant-stock-quantity/29/1 "2017-08-03T09:42:12Z")

</div>

Issue:  
I’ve created a product with one product variant via API. I set a price and stock quantity to it. That works ok.  
But, when I update a product via API, adding to it product variants, as a product\_variants\_attributes field without specifying product variant id, it creates a product variant correctly, with correct price, without stock\_entries. When I send an update stock quantity request for this sellable, I have a 404 status code in response. Even though that sellable id is present in product product variants.  
Even If i try to change the stock quantity on your UI, stock quantity does not change, but stock quantity of product variant created firstly changes successfully.  
Thanx

---

<div class="post-metadata">

**Author:** ![phil](https://yyz1.discourse-cdn.com/flex033/user_avatar/developer-forum.veeqo.com/phil/32/43_2.png) [@phil](https://developer-forum.veeqo.com/u/phil)\
**Post date:** [August 3, 2017, 10:13am UTC](https://developer-forum.veeqo.com/t/error-while-updating-product-variant-stock-quantity/29/2 "2017-08-03T10:13:58Z")

</div>

It looks as though you’re getting that error because the created\_by\_id isn’t set. This might be because the field is getting overwritten by the update request. This shouldn’t be the case and we will investigate why this is happening on our end.

For now please can you try updating again and ensure that you include created\_by in the update PUT request.

---

<div class="post-metadata">

**Author:** ![Andriy](https://yyz1.discourse-cdn.com/flex033/user_avatar/developer-forum.veeqo.com/andriy/32/28_2.png) [@Andriy](https://developer-forum.veeqo.com/u/Andriy)\
**Post date:** [August 3, 2017, 11:08am UTC](https://developer-forum.veeqo.com/t/error-while-updating-product-variant-stock-quantity/29/3 "2017-08-03T11:08:09Z")

</div>

Sorry, but can you attach some example  
Which value should I set to created\_by field?  
My user’s id?

---

<div class="post-metadata">

**Author:** ![phil](https://yyz1.discourse-cdn.com/flex033/user_avatar/developer-forum.veeqo.com/phil/32/43_2.png) [@phil](https://developer-forum.veeqo.com/u/phil)\
**Post date:** [August 3, 2017, 11:29am UTC](https://developer-forum.veeqo.com/t/error-while-updating-product-variant-stock-quantity/29/4 "2017-08-03T11:29:26Z")

</div>

As long as it is set to a user\_id within that company it should work fine.

Ideally it will be maintained by using the same ID that it was initially created with.

I presume you do a GET request at some point to get the product ID that you want to update, at this point you would ideally also fetch the created\_by\_id and maintain it.

---

<div class="post-metadata">

**Author:** ![Andriy](https://yyz1.discourse-cdn.com/flex033/user_avatar/developer-forum.veeqo.com/andriy/32/28_2.png) [@Andriy](https://developer-forum.veeqo.com/u/Andriy)\
**Post date:** [August 3, 2017, 12:26pm UTC](https://developer-forum.veeqo.com/t/error-while-updating-product-variant-stock-quantity/29/5 "2017-08-03T12:26:18Z")

</div>

That was my problem, Thank you, Phil  
It is solved now 🙂

---

<div class="post-metadata">

**Author:** ![phil](https://yyz1.discourse-cdn.com/flex033/user_avatar/developer-forum.veeqo.com/phil/32/43_2.png) [@phil](https://developer-forum.veeqo.com/u/phil)\
**Post date:** [August 3, 2017, 12:37pm UTC](https://developer-forum.veeqo.com/t/error-while-updating-product-variant-stock-quantity/29/6 "2017-08-03T12:37:14Z")

</div>

Awesome! Glad to hear
