Unable to use both CreateDynamicContentsClient and QueryContext.Default.Flatten()

I’m submitting a…

  • [ ] Regression (a behavior that stopped working in a new release)
  • [x] Bug report
  • [ ] Performance issue
  • [ ] Documentation issue or request

Current behavior

I’m getting a deserialization error when querying data using a flattened context and a dynamic content client in the .NET SDK. The error is "ArgumentException: The value “Sandra” is not of type “Newtonsoft.Json.Linq.JObject” and cannot be used in this generic collection. (Parameter ‘value’)"

Expected behavior

No error on Deserialization.

Minimal reproduction of the problem

  • Create a simple schema called “mylittlepony”
  • Create a field on that schema called “name”
  • Create a piece of content based on “mylittlepony” with the name “Sandra” and publish etc.
  • Use the C# client manager with CreateDynamicContentsClient for the “mylittlepony” schema
  • Create a query context with Flatten enabled i.e QueryContext.Default.Flatten();
  • Observe error


  • [ ] Self hosted with docker
  • [ X ] Self hosted with IIS
  • [ ] Self hosted with other version
  • [ ] Cloud version

Version: 4.5.1 (Squidex), 5.3.0 (SquidexClientLibrary)


  • [ X ] Chrome (desktop)
  • [ ] Chrome (Android)
  • [ ] Chrome (iOS)
  • [ ] Firefox
  • [ ] Safari (desktop)
  • [ ] Safari (iOS)
  • [ ] IE
  • [ ] Edge

This issue doesn’t happen with GraphQL, I believe it is because the returned root object is always nested so the dynamic map works.

You can easily create you own dynamic data for this matter

this could work:

namespace Squidex.ClientLibrary
    public sealed class DynamicContent : Content<DynamicData>

    public sealed class DynamicData : Dictionary<string, JToken> // CHANGE HERE

:man_facepalming: I had tried to do that earlier albeit with variations other than a JToken. This appears to be working as expected now.

Thanks very much for your help!

1 Like

I have changed it client library.