Custom model issues

Hello I’m using a custom model to build home page data.

Here is the model.

public sealed class HomePageData : IBasePage
    {
        [JsonConverter(typeof(InvariantConverter))]
        public string AppName { get; set; }

        [JsonConverter(typeof(InvariantConverter))]
        public string Title { get; set; }

        [JsonConverter(typeof(InvariantConverter))]
        public string Slug { get; set; }

        [JsonConverter(typeof(InvariantConverter))]
        public string ClanName { get; set; }

        [JsonConverter(typeof(InvariantConverter))]
        public string Slogan { get; set; }

        [JsonConverter(typeof(InvariantConverter))]
        public string ReadMoreText { get; set; }

        [JsonConverter(typeof(InvariantConverter))]
        public string HeroImage { get; set; }

        [JsonConverter(typeof(InvariantConverter))]
        public string CommunitiesTitle { get; set; }

        [JsonConverter(typeof(InvariantConverter))]
        public string CommunitiesHeader { get; set; }

        [JsonConverter(typeof(InvariantConverter))]
        public List<GameCommunity> Communities { get; set; }

        [JsonConverter(typeof(InvariantConverter))]
        public string SpotLightHeader { get; set; }

        [JsonConverter(typeof(InvariantConverter))]
        public string SpotlightDEscription { get; set; }

        [JsonConverter(typeof(InvariantConverter))]
        public MemberSpotlight MemberSpotlight { get; set; }

        [JsonConverter(typeof(InvariantConverter))]
        public string Subheader { get; set; }

        [JsonConverter(typeof(InvariantConverter))]
        public string WhyHeader { get; set; }

        [JsonConverter(typeof(InvariantConverter))]
        public List<CommunityBenefit> CommunityBenefits { get; set; }
    }
var page = await pagesClient.GraphQlAsync<JToken>(query);

return page.ToObject<HomePage>();

When the controller gets the model I see this error in the watch window.

AppName = ‘page.AppName’ threw an exception of type ‘System.InvalidOperationException’
‘page.SchemaName’ threw an exception of type ‘System.InvalidOperationException’

Please post the full exception information

'page.AppName' threw an exception of type 'System.InvalidOperationException'
   at Squidex.ClientLibrary.Content`1[[Absolved.Models.Pages.HomePageData, Absolved, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].GetDetails()
   at Squidex.ClientLibrary.Content`1[[Absolved.Models.Pages.HomePageData, Absolved, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].get_AppName()

'page.SchemaName' threw an exception of type 'System.InvalidOperationException'
"   at Squidex.ClientLibrary.Content`1[[Absolved.Models.Pages.HomePageData, 
Absolved, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].GetDetails()\r\n 

at Squidex.ClientLibrary.Content`1[[Absolved.Models.Pages.HomePageData, 
Absolved, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].get_SchemaName()"

Which Squidex version do you use?

I’m using a cloud version so I’m not sure how to tell. I could do a screen share since it’s a holiday here.

The Content class expect that is used with the REST API and therefore assumes that several other fields are available:

I’m seeing that error in the Locals window

Content has no self link

Maybe my model isn’t built properly?

That’s what the model I’m actually passing to the controller looks like.

using Squidex.ClientLibrary;

namespace Absolved.Models.Pages
{
    public sealed class HomePage : Content<HomePageData>
    {
    }
}

I should mention I’m using GraphQL to get the page data since I have a lot of referenced content.

Yes, I have seen it. Therefore I have said it: It assumes that it is used with REST. You have to create your own class for now.

Any examples I can use for reference?

You can just copy and paste content,. the only problem are the properties that use the links.

Yeah I was going to try that initially but what you just replied was what I was concerned about which is what prompted my question.

@Sebastian
Could you please share the class as I tried to create my own class but issue is being inherited from Contentbase class - public abstract class ContentBase : Entity ?

I am not sure what exactly you mean. This topic is 2 years old so I need a little bit more context.

@Sebastian
There is an issue comes up when I use the Entity object on the Page coming from here. With DataClass it works fine but that is not a project architecture. Entity Object is inherited from Content

if (!Links.TryGetValue(“self”, out var self))
{
throw new InvalidOperationException(“Content has no self link.”);
}

Still don’t get it. What squidex version do you use and what is “from here” and what project architecture?

@Sebastian
I am using version - 7.5.0.0 for the admin. Issues are in the client application which is using Squidex.ClientLibrary version 15.1.0.

I am extending the Squidex Identity project so same architecture is followed.

For the time being, I have initialized Dataclass as passing it instead of Entity class and resolved the issue but another Solved issue came up.

I see a validation error “Not a known field” for all the properties of the Data class while creating a record - [SOLVED] Component - Not a Known Field Validation Error

Please help as struggling with these 2 issues for days now

Can you give a code example?

@Sebastian
I will have to share the complete project for your reference but mainly I am using Squidex.Identity

Could you please let me know when such an error occurs like with what kind of properties/fields?

Sounds like your schema is empty and has no fields or it is a casing issue.

See https://docs.squidex.io/02-documentation/software-development-kits/.net-standard#control-the-casing (I just added that)