I'm returning data from a .NET Core 3.X API but keep getting this strange error:
System.Text.Json.JsonException: A possible object cycle was detected which is not supported. This can either be due to a cycle or if the object depth is larger than the maximum allowed depth of 32.
Here is what I'm doing with the data before immediately returning it after.
var bookings = bookingData
.Select(x => new SpecialTaskVm(new TaskViewModel(x, null))
{
client = x.Client,
carer = x.Carer,
carer2 = x.Carer2
})
.ToList();
I have tried changing the controller method type
I expect the data to return normally rather than a 500 error