ShopifySharp
ShopifySharp copied to clipboard
Product UpdateAsync - could not update variants to []
We are getting and exception when try to update product without any variants. Is that the expected behavior of the end point? If so how can we remove the variants.
could not update variants to [] at ShopifySharp.ShopifyService.CheckResponseExceptions(HttpResponseMessage response, String rawResponse) at ShopifySharp.ShopifyService.<>c__DisplayClass21_01.<<ExecuteRequestAsync>b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at ShopifySharp.DefaultRequestExecutionPolicy.Run[T](CloneableRequestMessage request, ExecuteRequestAsync1 executeRequestAsync) at ShopifySharp.ShopifyService.ExecuteRequestAsync[T](RequestUri uri, HttpMethod method, HttpContent content, String rootElement) at ShopifySharp.ProductService.UpdateAsync(Int64 productId, Product product)
As far as I know this is not expected, but it’s possible Shopify has changed the behavior in the API version we’re now targeting. Can you post the code you’re using to update the product?
Below is how we call the service end point.
`ProductService productService = new ProductService(channel.Host, secondary ? channel.SecondaryToken : channel.Token);
shopifyProduct = await productService.UpdateAsync((long)shopifyProduct.Id, shopifyProduct);`
Where is that shopifyProduct coming from, and which properties are you trying to change when updating it? That information will help me track down where the problem may lie.
It has all the information such as,
Title, Options, BodyHtml, ProductType, Variants, etc. variants property is empty as below,

I see, if you set the variants property to null before updating, does that change anything?
@nozzlegear yes it worked when you set the variants property to null, when its empty it gives the error.
I have the same issue. We cannot set variants property to null, as we need to update the product variants.
Any updates on why this occour?