if i add a item to cart via api it set Magento 2 default price of the item instead price set via API
1st i create a cart for a customer:
index.php/rest/default/V1/customers/631/carts
via POST
index.php/rest/default/V1/carts/{cartid}/items
via POST
json:
{ "cartItem": { "quote_id": "cart_id_from_1st_response", "sku": "test_sku", "qty": 1, "price": "11" } }
the response is like that:
stdClass Object ( [item_id] => 186 [sku] => test_sku [qty] => 1 [name] => Testarticle [price] => 15 [product_type] => simple [quote_id] => 287 )
the price should be 11 as in the post, but the API response the prie of 15
- 
 want You to post custom price which you have sent from post parametersAmit Bera– Amit Bera ♦2019年05月23日 09:21:11 +00:00Commented May 23, 2019 at 9:21
1 Answer 1
/V1/carts/{cartId}/items is an endpoint for GET request.
Try with the following endpoint instead: 
For POST:
/V1/carts/{quoteId}/items
/V1/carts/mine/items
For PUT
/V1/carts/{cartId}/items/{itemId} 
/V1/carts/mine/items/{itemId}
- 
 quoteId and cartId are still the same? the response of POST V1/customers/631/carts is the id to which i post the itemsJan– Jan2019年05月23日 14:07:38 +00:00Commented May 23, 2019 at 14:07
- 
 @Jan I'm not really sure but I think is the same. The id fromV1/customers/631/cartsis the quoteId you use to POST items to cart using/V1/carts/{quoteId}/itemsendpoint and then from there, you get the cart id from response which you use to update the cart items using/V1/carts/{cartId}/items/{itemId}endpointfmsthird– fmsthird2019年05月24日 04:05:38 +00:00Commented May 24, 2019 at 4:05
- 
 yes i think im right but...i send to the endpoint this json:{ "cartItem": { "item_id": 189, "quoteId":289, "price": 89, "qty":1 } }and get this response:{ "cartItem": { "item_id": 189, "quoteId":289, "price": 89, "qty":1 } }so the price will not acceptJan– Jan2019年05月25日 11:01:54 +00:00Commented May 25, 2019 at 11:01