This question already has answers here: How to exclude property from Json Serialization (8 answers) Your post has been associated with a similar question. If this question doesn’t resolve your question, ask a new one.
Closed 16 mins ago.
(Private feedback for you)
I have a class
public class Product
{
public int ProductId {get;}
public string Name {get;set;}
[ForeignKey("CategoryId")]
public int CategoryId {get; set;}
public Category Category {get;}
}
and another class
public class Category
{
public int CategoryId {get;}
public string Name {get;set;}
}
But in my body post method it appears like this
{
"name": "Fast and furious",
"categoryId": 2,
"category": {
"nome": "string"
}
}
I would like to appears like this
{
"name": "Fast and furious",
"categoryId": 2
}