Home > database >  How to remove unwanted properties from object while making Put Request
How to remove unwanted properties from object while making Put Request

Time:12-24

I am using the asp.net application integrated with the Shopify e-commerce store. I have a Variant class that contains some properties like below:

public class Variant{
    public long Id { get; set; }
    public string Title { get; set; }
    public decimal Weight { get; set; }
    public decimal Price { get; set; }
    public int Quantity { get; set; }

}

The problem is with Quantity property. When making a Post request, it allows to define quantity, but when making a Put request, it won't allow sending this Quantity property in the object.

I want to ignore this Quantity property while making a Put request

CodePudding user response:

maybe you can put the below line in the property you want to ignore when null but this is if you serialize that with Json.NET.

[JsonProperty(NullValueHandling=NullValueHandling.Ignore)]

Check out this great article

  • Related