collect-totals api call format is incorrect
See original GitHub issuein src/api/cart.js, the api call for collect-totals should be ‘PUT’ instead of ‘POST’, and the body format is incorrect now.
See reference: https://devdocs.magento.com/redoc/2.3/admin-rest-api.html#operation/quoteCartTotalManagementV1CollectTotalsPut
cartApi.post('/collect-totals', (req, res) => { const cartProxy = _getProxy(req) res.setHeader('Cache-Control', 'no-cache, no-store'); if (!req.body.methods) { return apiStatus(res, 'No shipping and payment methods element provided within the request body', 500) } cartProxy.collectTotals(req.query.token, req.query.cartId ? req.query.cartId : null, req.body.methods).then((result) => {
should be
cartApi.put('/collect-totals', (req, res) => { const cartProxy = _getProxy(req) res.setHeader('Cache-Control', 'no-cache, no-store'); if (!req.body.methods) { return apiStatus(res, 'No shipping and payment methods element provided within the request body', 500) } cartProxy.collectTotals(req.query.token, req.query.cartId ? req.query.cartId : null, req.body).then((result) => {
and when developer call from action.ts in VSF, the payload body should follow the format in magento API reference.
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (3 by maintainers)
Top GitHub Comments
Oh I see - pretty interesting case. Could you propose a PR with a general change? Otherwise you might want to use magento2-rest-client addMethods to add this collect totals: https://github.com/DivanteLtd/magento2-rest-client
OK sure