I have the following class:
public class UpdateActionRequest
{
[Required]
public int ActionId { get; set; }
[Required]
public int LeadId { get; set; }
[Required]
public int AssignedToUserId { get; set; }
public string Note { get; set; }
public DateTime? PlannedDate { get; set; }
}
Which I use in an api call:
[HttpPatch("update", Name = nameof(UpdateAction))]
public async Task<LeadAction> UpdateAction(UpdateActionRequest request)
{
return await _actionsHandler.Value.UpdateAction(request);
}
But when I send the following JSON:
{
"ActionId":7,
"LeadId":40,
"AssignedToUserId": 8306,
"PlannedDate":"2022-11-14T11:23:45.343Z"
}
I'm getting a bad request saying the note field is required - how do I make it so that I don't need to send the note property?
CodePudding user response:
you can use
public string? Note { get; set; };
or
public string Note { get; set; } = string.Empty;