question

maxyflux avatar image
maxyflux asked David Marginian commented

Adding item modifications to atomic order returns 400

I am doing some testing in sandbox and am running into an error when using line item modifications.

I am creating orders in two steps. First with `POST /v3/merchants/{mId}/atomic_order/checkouts` with the body:

{
  "orderCart": {
    "lineItems": [
      {
        "item": {
          "id": "HX1A3W7GH5HAJ"
        },
        "modifications": [
          {
            "modifier": {
              "id": "91N3C8539H7SE",
              "modifierGroup": {
                "id": "Z5FYG3J9SZV4M"
              }
            }
          }
        ]
      }
    ],
    "groupLineItems": true,
    "currency": "GBP"
  }
}

I have checked that the modifier IDs are correct by referencing `GET /v3/merchants/{mId}/modifier_groups`:

{
  "id": "Z5FYG3J9SZV4M",
  "name": "Shoe Material",
  "maxAllowed": 1,
  "showByDefault": false,
  "modifierIds": "91N3C8539H7SE,GXGFSPPKBJQQ8,C2ABE6P5Y9460"
}

So, I take the output from `/atomic_order/checkouts` and feed it into `POST /v3/merchants/{mId}/atomic_order/orders` (only showing relevant stuff):

{
  "lineItems": {
    "elements": [
      {
        "item": {
          "id": "HX1A3W7GH5HAJ"
        },
        "name": "Swanky Shoes",
        "price": 2300,
        "itemCode": "shoo-de-woo",
        "modifications": {
          "elements": [
            {
              "modifier": {
                "id": "91N3C8539H7SE",
                "modifierGroup": {
                  "id": "Z5FYG3J9SZV4M"
                }
              }
            }
          ]
        },
        "refunded": false,
        "isRevenue": true
      }
    ]
  }
}

This gives me a 400 response with the plain text

"The operation could not be completed due to a data validation error."


I've played about with the request body to `/atomic_order/checkouts` to try and get a different outcome, but the only thing that prevents the error is removing the modifications. Is there something silly that I'm doing wrong?

REST API
10 |2000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

David Marginian avatar image
David Marginian answered
10 |2000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

maxyflux avatar image
maxyflux answered David Marginian commented

Thank you David! Adding name and amount to the modification did the trick. I figured it would work like it does when adding items by ID, and those fields are not marked as required in the docs.

1 comment
10 |2000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Yeah, I know it isn't clear. Glad you got it working.
0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Welcome to the
Clover Developer Community