Skip to content

Guest cart API ignoring cartId in url for some methods #14086

Closed

Description

@midlan

Preconditions

  1. Magento 2.2.3

Steps to reproduce

I am following the API documentation to create guest cart and add item to it:

  1. POST https://yourdomain/rest/default/V1/guest-carts (with empty body) creates cart for you and return cartId in body
  2. GET https://yourdomain/rest/default/V1/guest-carts/:cartId to check you cart is created
  3. POST https://yourdomain/rest/default/V1/guest-carts/:cartId/items with body
{
  "cartItem": {
    "sku": "WS12-M-Orange",
    "qty": 3
  }
}

to add item to your cart, but error is returned instead of adding cart to item

Expected result

In step 3, I was expecting the added item to be returned. Instead of that, error is returned.

Actual result

{
    "message": "No such entity with %fieldName = %fieldValue",
    "parameters": {
        "fieldName": "cartId",
        "fieldValue": null
    },
    "trace": "..."
}

Further research

I discovered: If you send the cartId in quote_id field in body at step 3, the method would work. So the body would be:

{
  "cartItem": {
    "sku": "WS12-M-Orange",
    "qty": 3,
    "quote_id": ":cartId"
  }
}

And the results is cart item, no error. The cartId in url is completly ignored. If you use send request with some dummy string instead of cartId in URL (with the body with quote_id field), it actually works.

So request like
POST https://yourdomain/rest/default/V1/guest-carts/some_dummy_string_insetead_of_cartId/items
works. But it should not! And the mandatory quote_id in body is also wrong I think. The only cartId needed to add the item to the cart should be the one from URL (which is not used at all at the moment).

The same problem is present on other methods in guest-cart.

Activity

  1. added
    Issue: Format is validGate 1 Passed. Automatic verification of issue format passed
    Issue: Ready for WorkGate 4. Acknowledged. Issue is added to backlog and ready for development
    Issue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmed
    Reproduced on 2.1.xThe issue has been reproduced on latest 2.1 release
    Reproduced on 2.2.xThe issue has been reproduced on latest 2.2 release
    Reproduced on 2.3.xThe issue has been reproduced on latest 2.3 release
    Issue: Clear DescriptionGate 2 Passed. Manual verification of the issue description passed
    on Mar 13, 2018
  2. magento-engcom-team commented on Mar 14, 2018

    @magento-engcom-team
    Contributor

    @midlan, thank you for your report.
    We've acknowledged the issue and added to our backlog.

  3. elzekool commented on Mar 17, 2018

    @elzekool
    Contributor

    I've created a PR for this issue. Investigating this a little further I found a related issue for the normal cart API. In the case /V1/carts/mine/items is used it allows adding/editing items to a quote different then the actual customer quote.

  4. self-assigned this
    on Jan 3, 2020
  5. m2-assistant commented on Jan 3, 2020

    @m2-assistant

    Hi @engcom-Bravo. Thank you for working on this issue.
    Looks like this issue is already verified and confirmed. But if you want to validate it one more time, please, go though the following instruction:

    • 1. Add/Edit Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

    • 2. Verify that the issue is reproducible on 2.4-develop branch

      Details- Add the comment @magento give me 2.4-develop instance to deploy test instance on Magento infrastructure.
      - If the issue is reproducible on 2.4-develop branch, please, add the label Reproduced on 2.4.x.
      - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!

    • 3. If the issue is not relevant or is not reproducible any more, feel free to close it.


  6. 3 remaining items

  7. added
    Issue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmed
    on Jan 3, 2020
  8. Repository owner unassigned on Jan 3, 2020
  9. magento-engcom-team commented on Jan 3, 2020

    @magento-engcom-team
    Contributor

    ✅ Confirmed by @engcom-Bravo
    Thank you for verifying the issue. Based on the provided information internal tickets MC-30200 were created

    Issue Available: @engcom-Bravo, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.

  10. m2-assistant commented on Mar 3, 2020

    @m2-assistant

    Hi @engcom-Charlie. Thank you for working on this issue.
    Looks like this issue is already verified and confirmed. But if you want to validate it one more time, please, go though the following instruction:

    • 1. Add/Edit Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

    • 2. Verify that the issue is reproducible on 2.4-develop branch

      Details- Add the comment @magento give me 2.4-develop instance to deploy test instance on Magento infrastructure.
      - If the issue is reproducible on 2.4-develop branch, please, add the label Reproduced on 2.4.x.
      - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!

    • 3. If the issue is not relevant or is not reproducible any more, feel free to close it.


  11. magento-engcom-team commented on Mar 12, 2020

    @magento-engcom-team
    Contributor

    Hi @midlan. Thank you for your report.
    The issue has been fixed in #27172 by @engcom-Charlie in 2.4-develop branch
    Related commit(s):

    The fix will be available with the upcoming 2.4.0 release.

  12. added 5 commits that reference this issue on Aug 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Component: ApiUse with concrete module component label E.g. "Component: Api" + "Catalog"Fixed in 2.4.xThe issue has been fixed in 2.4-develop branchIssue: Clear DescriptionGate 2 Passed. Manual verification of the issue description passedIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedIssue: Format is validGate 1 Passed. Automatic verification of issue format passedIssue: Ready for WorkGate 4. Acknowledged. Issue is added to backlog and ready for developmentReproduced on 2.1.xThe issue has been reproduced on latest 2.1 releaseReproduced on 2.2.xThe issue has been reproduced on latest 2.2 releaseReproduced on 2.3.xThe issue has been reproduced on latest 2.3 releaseReproduced on 2.4.xThe issue has been reproduced on latest 2.4-develop branch

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions