0

I have successfully run two REST API's but on running the third one

http://127.0.0.1/mag/rest/V1/guest-carts/81/items
{
"cart_item": {
    "quoteId": 81,
    "sku": "test",
    "qty": 1,
    "quote_id": "HWgMbh8XAVWzsakhskakjsassaas"
}
}

with this param

it will still give me this error

{
        "message": "\"%fieldName\" is required. Enter and try again.",
        "parameters": {
            "fieldName": "quoteId"
        },
        "trace": "#0 /var/www/html/reg-dealers/vendor/magento/module-quote/Model/GuestCart/GuestCartItemRepository.php(66): Magento\\Quote\\Model\\Quote\\Item\\Repository->save(Object(Magento\\Quote\\Model\\Quote\\Item))\n#1 /var/www/html/reg-dealers/vendor/magento/framework/Interception/Interceptor.php(58): Magento\\Quote\\Model\\GuestCart\\GuestCartItemRepository->save(Object(Magento\\Quote\\Model\\Quote\\Item))\n#2 /var/www/html/reg-dealers/vendor/magento/framework/Interception/Interceptor.php(138): Magento\\Quote\\Model\\GuestCart\\GuestCartItemRepository\\Interceptor->___callParent('save', Array)\n#3 /var/www/html/reg-dealers/vendor/magento/framework/Interception/Interceptor.php(153): Magento\\Quote\\Model\\GuestCart\\GuestCartItemRepository\\Interceptor->Magento\\Framework\\Interception\\{closure}(Object(Magento\\Quote\\Model\\Quote\\Item))\n#4 /var/www/html/reg-dealers/generated/code/Magento/Quote/Model/GuestCart/GuestCartItemRepository/Interceptor.php(26): Magento\\Quote\\Model\\GuestCart\\GuestCartItemRepository\\Interceptor->___callPlugins('save', Array, Array)\n#5 [internal function]: Magento\\Quote\\Model\\GuestCart\\GuestCartItemRepository\\Interceptor->save(Object(Magento\\Quote\\Model\\Quote\\Item))\n#6 /var/www/html/reg-dealers/vendor/magento/module-webapi/Controller/Rest/SynchronousRequestProcessor.php(95): call_user_func_array(Array, Array)\n#7 /var/www/html/reg-dealers/vendor/magento/module-webapi/Controller/Rest.php(188): Magento\\Webapi\\Controller\\Rest\\SynchronousRequestProcessor->process(Object(Magento\\Framework\\Webapi\\Rest\\Request\\Proxy))\n#8 /var/www/html/reg-dealers/vendor/magento/framework/Interception/Interceptor.php(58): Magento\\Webapi\\Controller\\Rest->dispatch(Object(Magento\\Framework\\App\\Request\\Http))\n#9 /var/www/html/reg-dealers/vendor/magento/framework/Interception/Interceptor.php(138): Magento\\Webapi\\Controller\\Rest\\Interceptor->___callParent('dispatch', Array)\n#10 /var/www/html/reg-dealers/vendor/magento/framework/Interception/Interceptor.php(153): Magento\\Webapi\\Controller\\Rest\\Interceptor->Magento\\Framework\\Interception\\{closure}(Object(Magento\\Framework\\App\\Request\\Http))\n#11 /var/www/html/reg-dealers/generated/code/Magento/Webapi/Controller/Rest/Interceptor.php(26): Magento\\Webapi\\Controller\\Rest\\Interceptor->___callPlugins('dispatch', Array, Array)\n#12 /var/www/html/reg-dealers/vendor/magento/framework/App/Http.php(116): Magento\\Webapi\\Controller\\Rest\\Interceptor->dispatch(Object(Magento\\Framework\\App\\Request\\Http))\n#13 /var/www/html/reg-dealers/vendor/magento/framework/App/Bootstrap.php(263): Magento\\Framework\\App\\Http->launch()\n#14 /var/www/html/reg-dealers/index.php(42): Magento\\Framework\\App\\Bootstrap->run(Object(Magento\\Framework\\App\\Http\\Interceptor))\n#15 {main}"
    }

Any idea i have added that key but still give me this error.

Any help is appriciated.

1 Answer 1

3
  1. Create a request to create the empty cart POST {{magento_api_url}}/rest/default/V1/guest-carts/ - this will return a token which is the cart ID (e.g 'KZepbhhPiGORreBKqIRlMCywGDTyQtR4')
  2. Use that cart ID in the request which adds item to the cart POST {{magento_api_url}}/rest/default/V1/guest-carts/KZepbhhPiGORreBKqIRlMCywGDTyQtR4/items with the payload similar to what you see below (where quote_id is the key you previously used and the sku is the SKU of the product you want to add):
{
    "cartItem": {
        "qty": 5,
        "sku": "24-UG06"
    }
}
3

Your Answer

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

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