question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

collect-totals api call format is incorrect

See original GitHub issue

in 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:open
  • Created 4 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
pkarwcommented, May 1, 2019

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

0reactions
michhycommented, May 1, 2019

OK sure

Read more comments on GitHub >

github_iconTop Results From Across the Web

collect-totals api call format is incorrect · Issue #228 - GitHub
in src/api/cart.js, the api call for collect-totals should be 'PUT' instead of 'POST', and the body format is incorrect now.
Read more >
M2: Wrong totals, if I change item customPrice after quote ...
Unfortunately, it doesn't work. And there is a question: What am I doing wrong? :) It happens if quote already exists in the...
Read more >
How a wrong carrier implementation causes a server outage
It's an infinite loop! Quote::collectTotals() will trigger shipping carriers' method collectRates() and thats where the loop is closed. The ...
Read more >
Update cart item price after collect totals magento2
try remove $quote->setTotalsCollectedFlag(false); or call $quote->collectTotals(); after you changed price. I see it helped some people.
Read more >
The API is not working for me. What should I do?
You can learn more about these APIs, data formats and authentication here. ... Check that you are including your API key in your...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found