I'm trying to read this Json file (types.json):
{
"types": [
"serveur d'application",
"serveur de donnees",
"serveur de proxy"
]
}
with the following function in my controller:
[HttpGet("/types")]
public async Task<ActionResult<Types>> GetInstancesTypes()
{
Types typesGet;
using (StreamReader r = new StreamReader("../types.json"))
{
string json = r.ReadToEnd();
typesGet = JsonConvert.DeserializeObject<Types>(json);
}
return typesGet;
}
The class Types is:
public class Types
{
public IList<string> types { get; set; }
}
When I go to the link where I should see the result it gives me this error:
{
"type": "https://tools.ietf.org/html/rfc7231#section-6.5.1",
"title": "One or more validation errors occurred.",
"status": 400,
"traceId": "|b6dd40c-4159a247507490ac.",
"errors": {
"id": [
"The value 'types' is not valid."
]
}
}
Any help would be appreciated thank you :)