I made an API route that will take an array of CartItemInterface objects and modify them with just one call (to reduce multiple calls). The problem I am facing is that it is giving me this error in the logs:

Property "0" does not have corresponding setter in class "Magento\Quote\Api\Data\CartItemInterface".

I do have a feeling the API is thinking that part of the request data is just a single object, not an array of objects hence thinking "0", which might be the array index 0.


<route url="/V1/foo/carts/mine/items" method="PUT">
    <service class="{Vendor}\{Module}\Api\Magento_Quote\CartItemRepositoryInterface" method="saveAsUser" />

        <resource ref="self" />

        <parameter name="cartId" force="true">%cart_id%</parameter>


namespace {Vendor}\{Module}\Api\Magento_Quote;

interface CartItemRepositoryInterface

     * Add/update an array of cart items
     * @param int $cartId
     * @param \Magento\Quote\Api\Data\CartItemInterface[] $cartItems
     * @return \Magento\Quote\Api\Data\CartItemInterface[]
    public function saveAsUser($cartId, \Magento\Quote\Api\Data\CartItemInterface $cartItems);

Request Data

    "cartItems": [
        0: "--Cart Item--",
        1: "--Cart Item--"

I had looked around for questions similar in nature:

Property "0" does not have corresponding setter in class "Magento\Sales\Api\Data\OrderPaymentInterface"

But the question did not have any solid answers.

How to set Interfaces for custom module API creation in Magento2

Tried something similar to this question:

you cant sent an array at very first object.

I modified the request data to:

    "cartId": '123',
    "cartItems": [
        0: "--Cart Item--",
        1: "--Cart Item--"

Still getting the same error.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.