I added this in global.asax and it started working
GlobalConfiguration.Configuration.Formatters.XmlFormatter.SupportedMediaTypes.Clear();
Product[] products = new Product[]
{
new Product { Id = 1, Name = "Player1", position="Midfielder" },
new Product { Id = 2, Name = "Player2",Position="Defender"}
};
public IEnumerable<Product> GetAllProducts()
{
return products;
}
How do I add player skills to return the below json format please note player skills could be an array for a single Player.
[
{
"id": 1,
"name": "player name 1",
"position": "defender",
"playerSkills": [
{
"id": 1,
"skill": "defense",
"value": 60,
"playerId": 1
},
{
"id": 2,
"skill": "speed",
"value": 80,
"playerId": 1
}
]
},
{
"id": 2,
"name": "player name 2",
"position": "midfielder",
"playerSkills": [
{
"id": 3,
"skill": "attack",
"value": 20,
"playerId": 2
},
{
"id": 4,
"skill": "speed",
"value": 70,
"playerId": 2
}
]
}
]