Storefront api addLineItems INVALID

Igor10
Shopify Partner
5 0 0

Hi, I create product in shopify via api (/admin/products.json)

ready product is https://plattenplaner-shop.myshopify.com/admin/products/1766639337515/variants/16029289414699

then by means of 'shopify-buy'-sdk I add line items

 

request is folowing:

{  
   "query":"fragment VariantFragment on ProductVariant  { id,title,price,weight,available: availableForSale,sku,compareAtPrice,image { id,src: originalSrc,altText },selectedOptions { name,value } },fragment DiscountApplicationFragment on DiscountApplication  { __typename,targetSelection,allocationMethod,targetType,... on ManualDiscountApplication { title,description },... on DiscountCodeApplication { code,applicable },... on ScriptDiscountApplication { description },... on AutomaticDiscountApplication { title } },fragment VariantWithProductFragment on ProductVariant  { ...VariantFragment,product { id } },fragment UserErrorFragment on UserError  { field,message },fragment CheckoutUserErrorFragment on CheckoutUserError  { field,message,code },fragment MailingAddressFragment on MailingAddress  { id,address1,address2,city,company,country,firstName,formatted,lastName,latitude,longitude,phone,province,zip,name,countryCode: countryCodeV2,provinceCode },fragment CheckoutFragment on Checkout  { id,ready,requiresShipping,note,paymentDue,webUrl,orderStatusUrl,taxExempt,taxesIncluded,currencyCode,totalTax,subtotalPrice,totalPrice,completedAt,createdAt,updatedAt,email,discountApplications (first: 10) { pageInfo { hasNextPage,hasPreviousPage },edges { node { __typename,...DiscountApplicationFragment } } },shippingAddress { ...MailingAddressFragment },shippingLine { handle,price,title },customAttributes { key,value },order { id,processedAt,orderNumber,subtotalPrice,totalShippingPrice,totalTax,totalPrice,currencyCode,totalRefunded,customerUrl,shippingAddress { ...MailingAddressFragment },lineItems (first: 250) { pageInfo { hasNextPage,hasPreviousPage },edges { cursor,node { title,variant { ...VariantWithProductFragment },quantity,customAttributes { key,value } } } } },lineItems (first: 250) { pageInfo { hasNextPage,hasPreviousPage },edges { cursor,node { id,title,variant { ...VariantWithProductFragment },quantity,customAttributes { key,value },discountAllocations { allocatedAmount { amount,currencyCode },discountApplication { __typename,...DiscountApplicationFragment } } } } } },mutation ($checkoutId:ID!,$lineItems:[CheckoutLineItemInput!]!)  { checkoutLineItemsAdd (checkoutId: $checkoutId lineItems: $lineItems) { userErrors { ...UserErrorFragment },checkoutUserErrors { ...CheckoutUserErrorFragment },checkout { ...CheckoutFragment } } }",
   "variables":{  
      "checkoutId":"Z2lkOi8vc2hvcGlmeS9DaGVja291dC81OTRhZTUwODMyYWRkZWY5NmU4NmFhYTIzNDRkYWYxZj9rZXk9MjJlYWYzNzc4YjFlMDI0MGFkYWE4YTQyNDgzYjZmZjU=",
      "lineItems":[  
         {  
            "variantId":"Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0VmFyaWFudC8xNjAyOTI4OTQxNDY5OQ==",
            "quantity":1
         }
      ]
   }
}

 

but the response:

{  
   "data":{  
      "checkoutLineItemsAdd":{  
         "userErrors":[  
            {  
               "field":[  
                  "lineItems",
                  "0",
                  "variantId"
               ],
               "message":"Variant ist ungültig"
            }
         ],
         "checkoutUserErrors":[  
            {  
               "field":[  
                  "lineItems",
                  "0",
                  "variantId"
               ],
               "message":"Variant ist ungültig",
               "code":"INVALID"
            }
         ],
         "checkout":{  
            "id":"Z2lkOi8vc2hvcGlmeS9DaGVja291dC81OTRhZTUwODMyYWRkZWY5NmU4NmFhYTIzNDRkYWYxZj9rZXk9MjJlYWYzNzc4YjFlMDI0MGFkYWE4YTQyNDgzYjZmZjU=",
            "ready":true,
            "requiresShipping":false,
            "note":null,
            "paymentDue":"0.00",
            "webUrl":"https:\/\/plattenplaner-shop.myshopify.com\/27782296\/checkouts\/594ae50832addef96e86aaa2344daf1f?key=22eaf3778b1e0240adaa8a42483b6ff5",
            "orderStatusUrl":null,
            "taxExempt":false,
            "taxesIncluded":true,
            "currencyCode":"EUR",
            "totalTax":"0.00",
            "subtotalPrice":"0.00",
            "totalPrice":"0.00",
            "completedAt":null,
            "createdAt":"2019-04-17T12:32:14Z",
            "updatedAt":"2019-04-17T12:32:14Z",
            "email":null,
            "discountApplications":{  
               "pageInfo":{  
                  "hasNextPage":false,
                  "hasPreviousPage":false
               },
               "edges":[  

               ]
            },
            "shippingAddress":null,
            "shippingLine":null,
            "customAttributes":[  

            ],
            "order":null,
            "lineItems":{  
               "pageInfo":{  
                  "hasNextPage":false,
                  "hasPreviousPage":false
               },
               "edges":[  

               ]
            }
         }
      }
   },
   "errors":[  
      {  
         "message":"access denied",
         "locations":[  
            {  
               "line":1,
               "column":1415
            }
         ],
         "path":[  
            "checkoutLineItemsAdd",
            "checkout",
            "order"
         ]
      }
   ]
}

 

My question is how is it possible if I've already created the product? or backend can't update the store of valid variantId-s?

Reply 1 (1)

Igor10
Shopify Partner
5 0 0

I guess the info provided is as specific as possible, isn't it?