Cannot add LineItem to cart with MerchandiseID from ProductVariant

Cannot add LineItem to cart with MerchandiseID from ProductVariant

_chath_s_
Tourist
5 0 6

Hi I am trying to add line items to the customer cart from STOREFRONT API as below with the merchandiseId (type ID) of the productVariant received from products query.: 

 

 

 

{
    "cartId": "Z2lkOi8vc2hvcGlmeS9DYXJ0L2U2ZmEyZjI0OTZmNGJhNjBmZWZmZWFlZWYxMTQyMzAx",
    "lines": [
        {
            "quantity": 1,
            "merchandiseId": "gid://shopify/ProductVariant/{id received from products query}"
        }
    ]
}

 

 

 

 

I am getting the below error:

 

The merchandise with id gid://shopify/ProductVariant/0 does not exist.

 

 

However, this does work if I provide the merchandiseId to be a string (same as whats in the url of the admin panel as below underlined in "yellow")
Screenshot 2022-02-15 at 12.01.22 PM.png
I am not sure how I can get this "string" type id, instead of the "ID" type id from the products query.

Replies 0 (0)