0

I am trying to call Magento 2 Quote rest api,

 <route url="/V1/carts/mine/coupons/:couponCode" method="PUT">
        <service class="Magento\Quote\Api\CouponManagementInterface" method="set"/>
        <resources>
            <resource ref="self" />
        </resources>
        <data>
            <parameter name="cartId" force="true">%cart_id%</parameter>
        </data>
    </route>

but i get issue like "\"%fieldName\" is required. Enter and try again.",

here is the screenshot. enter image description here

Can any one help me to resolve this. Thanks

1 Answer 1

0

If using PUT /V1/carts/mine/coupons/:couponCode or GET /V1/carts/mine/coupons, we don't need to pass cart_id.

cart_id will be overridden by vendor/magento/module-quote/etc/di.xml

<type name="Magento\Webapi\Controller\Rest\ParamsOverrider">
    <arguments>
        <argument name="paramOverriders" xsi:type="array">
            <item name="%cart_id%" xsi:type="object">Magento\Quote\Model\Webapi\ParamOverriderCartId\Proxy</item>
        </argument>
    </arguments>
</type>

Note: try to change GET to PUT. You're using wrong method?

2
  • yes, right. but still result is same. i have remove the cart_id from param. but no result. any other suggestion. Commented Feb 6, 2020 at 3:54
  • Did you try to change GET to PUT? Commented Feb 6, 2020 at 6:31

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.