3

I am building a shoppingcart using the Magento2 Rest API and I want to create a cart for a customer and (if not logged in) for a guest.

For guest carts is it working:

Create a guestcart:

POST /V1/guest-carts returns :cartId

Get guestcart:

GET /V1/guest-carts/:cartId returns cartObject

Fine so far, but for a customer who is logged in (using a customerToken) it doesn't work:

Create a customercart (using the customertoken):

POST /V1/carts/mine returns [message] => Cannot create quote

So i tried this workaround (using API token) but it returns the same message:

Create a customercart (using the API token):

POST /V1/customers/:customerId/carts returns [message] => Cannot create quote

I get the same result for different customers.

Does anyone has a clue?

Using Magento 2.2.5

TRACE

0 [internal function]: Magento\Quote\Model\QuoteManagement->createEmptyCartForCustomer(3)

1 /vendor/magento/module-webapi/Controller/Rest.php(330): call_user_func_array(Array, Array)

2 /vendor/magento/module-webapi/Controller/Rest.php(239): Magento\Webapi\Controller\Rest->processApiRequest()

3 /vendor/magento/framework/Interception/Interceptor.php(58): Magento\Webapi\Controller\Rest->dispatch(Object(Magento\Framework\App\Request\Http))

4 /vendor/magento/framework/Interception/Interceptor.php(138): Magento\Webapi\Controller\Rest\Interceptor->___callParent(dispatch, Array)

5 /vendor/magento/framework/Interception/Interceptor.php(153): Magento\Webapi\Controller\Rest\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))

6 /generated/code/Magento/Webapi/Controller/Rest/Interceptor.php(39): Magento\Webapi\Controller\Rest\Interceptor->___callPlugins('dispatch', Array, Array)

7 /vendor/magento/framework/App/Http.php(135): Magento\Webapi\Controller\Rest\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http))

8 generated/code/Magento/Framework/App/Http/Interceptor.php(24): Magento\Framework\App\Http->launch()

9 /vendor/magento/framework/App/Bootstrap.php(256): Magento\Framework\App\Http\Interceptor->launch()

10 index.php(39): Magento\Framework\App\Bootstrap->run(Object(Magento\Framework\App\Http\Interceptor))
2
  • Just quickly thinking here, not sure if I will help you, but have you tried to check the server side for error logs? Like Magento's var/log. See if anything gets logged there yet? It might give you clues about the problem I hope.
    – Marjan
    Sep 14, 2018 at 8:52
  • Thanks for the tip, but nothing useful in the log files unfortunately.
    – Frankey
    Sep 14, 2018 at 9:17

2 Answers 2

1

Guess what!? The problem was related to a Plesk setting overwriting the PHP include_path

https://github.com/magento/magento2/issues/10821#issuecomment-334525946

1
  • is it working fine now ? Sep 16, 2018 at 6:53
0

User below postman collection which have all api for create cart and add to product into the cart for magento 2.

https://www.getpostman.com/collections/a7900127aac366535a20

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.