AspNetCore.Docs
AspNetCore.Docs copied to clipboard
MongoDB WebAPI Example does not work
Description
Following these instructions led to I am running dot net 8 on my Mac.
###
System.NotSupportedException: JsonTypeInfo metadata for type 'System.Collections.Generic.List1[BookStore.Models.BookModel]' was not provided by TypeInfoResolver of type '[]'. If using source generation, ensure that all root types passed to the serializer have been annotated with 'JsonSerializableAttribute', along with any types that might be serialized polymorphically. at System.Text.Json.ThrowHelper.ThrowNotSupportedException_NoMetadataForType(Type type, IJsonTypeInfoResolver resolver) at System.Text.Json.JsonSerializerOptions.GetTypeInfoInternal(Type type, Boolean ensureConfigured, Nullable1 ensureNotNull, Boolean resolveIfMutable, Boolean fallBackToNearestAncestorType)
at System.Text.Json.JsonSerializerOptions.GetTypeInfo(Type type)
at Microsoft.AspNetCore.Mvc.Formatters.SystemTextJsonOutputFormatter.WriteResponseBodyAsync(OutputFormatterWriteContext context, Encoding selectedEncoding)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeResultAsync>g__Logged|22_0(ResourceInvoker invoker, IActionResult result)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResultFilterAsync>g__Awaited|30_0[TFilter,TFilterAsync](ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResultExecutedContextSealed context)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.ResultNext[TFilter,TFilterAsync](State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeResultFilters()
--- End of stack trace from previous location ---
###
When attempting, to test. Its as though the BSon Serializer Fails to serialise out the list of modes on the Get call, Fails at this level it wont get anywhere
Page URL
https://learn.microsoft.com/en-us/aspnet/core/tutorials/first-mongo-app?view=aspnetcore-9.0&tabs=visual-studio
Content source URL
https://github.com/dotnet/AspNetCore.Docs/blob/main/aspnetcore/tutorials/first-mongo-app.md
Document ID
83a5cb3b-23bc-4f0c-cd1c-1d1ffeb1131a
Platform Id
65f2481a-2462-7f68-0aa8-570bd4557d09
Article author
@wadepickett
Metadata
- ID: 5240866d-d0a1-f0dd-7b2c-203e1d69bc4b
- PlatformId: 65f2481a-2462-7f68-0aa8-570bd4557d09
- Service: aspnet-core
- Sub-service: tutorials