ShopifySharp icon indicating copy to clipboard operation
ShopifySharp copied to clipboard

Product UpdateAsync - could not update variants to []

Open madushann opened this issue 5 years ago • 7 comments

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)

madushann avatar Mar 06 '20 19:03 madushann

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?

nozzlegear avatar Mar 06 '20 19:03 nozzlegear

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);`

madushann avatar Mar 07 '20 03:03 madushann

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.

nozzlegear avatar Mar 07 '20 03:03 nozzlegear

It has all the information such as, Title, Options, BodyHtml, ProductType, Variants, etc. variants property is empty as below, image

madushann avatar Mar 07 '20 04:03 madushann

I see, if you set the variants property to null before updating, does that change anything?

nozzlegear avatar Mar 07 '20 04:03 nozzlegear

@nozzlegear yes it worked when you set the variants property to null, when its empty it gives the error.

madushann avatar Mar 11 '20 13:03 madushann

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?

simplenotezy avatar Jun 04 '21 13:06 simplenotezy