Invalid variant ID while creating checkout for Shopify

1k views Asked by At

I am trying to create checkout url using Admin API with following params.

URL: https://shopy-test11.myshopify.com/admin/api/2020-10/checkouts.json

{
  "checkout": {
    "line_items": [
      {
        "variant_id": 37033347711169,"quantity": 2
        
    }
    ]
  }
}

Unfortunately its returning below error which is not properly documented anywhere that I could find.

{
    "errors": {
        "line_items": {
            "0": {
                "variant_id": [
                    {
                        "code": "invalid",
                        "message": "is invalid",
                        "options": {}
                    }
                ]
            }
        }
    }
}

I also tried Shopify-api ruby gem and got same error. There are some similar issue online, but none answers why that issue is occurring and how to fix it. This is new app under development which will create custom checkout. There's only one sales channel which is "Online Store" and is enabled for all products. Any ideas how to fix this issue? Any help is appreciated.

1

There are 1 answers

0
David Lazar On BEST ANSWER

You seem to be mixing up concepts here. The checkout API is only associated with the Storefront API, and has nothing to do with the Admin API.

So this URL: /admin/api/2020-10/checkouts.json seems to be impossible. There is no endpoint in the admin API for checkouts, whereas, Storefront API which does have checkouts, might be your proper URL. So try that:

/api/2020-10/checkouts.json

And if you have the correct token in your header, it will likely work.