Код: Выделить всё
public class PositionGroup
{
[Key]
public int IdPoGr { get; set; }
[Required, MaxLength(150)]
public string Name { get; set; }
public ICollection
? positions { get; set; }
}
Код: Выделить всё
public class Position
{
[Key]
public int IdPos { get; set; }
[Required, MaxLength(150)]
public string PositionName { get; set; }
[ForeignKey("PositionGroup")]
public int IdPosGr { get; set; }
[Column(TypeName = "date")]
public DateTime CreateDate { get; set; }
public PositionGroup? positionGroup { get; set; }
}
Код: Выделить всё
{
"idPoGr": 0,
"name": "G1",
"positions": [
{
"idPos": 0,
"positionName": "string",
"idPosGr": 0,
"createDate": "2024-10-02T05:17:13.314Z",
"positionGroup": "string"
}
]
}
Код: Выделить всё
{
"type": "https://tools.ietf.org/html/rfc7231#section-6.5.1",
"title": "One or more validation errors occurred.",
"status": 400,
"traceId": "00-3b028362a6c027c0b63aa86cfee53628-50a135cc3612d607-00",
"errors": {
"positionGroup": [
"The positionGroup field is required."
],
"$.positions[0].positionGroup": [
"The JSON value could not be converted to API_CDE.Models.PositionGroup. Path: $.positions[0].positionGroup | LineNumber: 9 | BytePositionInLine: 31."
]
}
}
Я не знаю, как это исправить, потому что мне впервые приходится переходить с .NET 5 на .NET 6
Подробнее здесь: https://stackoverflow.com/questions/790 ... x-post-api
Мобильная версия