kontent-ai / management-sdk-net

Kontent.ai Management .NET SDK
https://www.nuget.org/packages/Kontent.Ai.Management
MIT License
7 stars 31 forks source link

Strongly typed language variants doesn't include values for Elements #183

Closed twadevs closed 2 years ago

twadevs commented 2 years ago

What I'm trying to do:

Hi,

I'm trying to use the .GetLanguageVariantAsync<T> method to retrieve strongly typed items. It seems to return the Item object (id, etc..) and last updated, etc.., but the Elements are all null.

Using the LanguageVariantModel without the strongly typed object works fine.

Repro steps

  1. Installed the latest Kentico Model Generator (v7.0.0)
  2. Generated models as per documentation
  3. Use the client.GetLanguageVariantAsync<T> method to retrieve the language variant
  4. The returned object doesn't include any values for the Elements

Expected behaviour

The strongly typed object should include values for the Elements.

Test environment

Screenshots

image

image

gormal commented 2 years ago

Do you mind sharing the whole JSON from API + the generated strongly-type model? It would help us with the investigation.

gormal commented 2 years ago

Hi!

This issue has gone quiet. 👻

It’s been a while since the last update here. If we missed anything on this issue or if you want to keep it open, please reply here.

Thanks for being a part of the Kontent.ai community!

twadevs commented 2 years ago

Just an update, if it helps, we eventually figured out what was going on:

We use the Kentico Model Generator to create the .Net models, but we used the same syntax in the CLI that we used in V1, which still generates models, but is entirely different to the new version. I assume this is for backward compatibility with Management API V1?

E.g. this is what we used in the CLI (and it still worked, generated models):

kontentModelGenerator.exe --projectid "<project id>" --contentmanagementapi true --namespace "TWA.Library.Models.Kentico.Management" --outputdir "<repo>\TWA.Library\Models\Kentico\Management"

But the new version expects the following argument instead:

--managementapi true

gormal commented 2 years ago

Happy to hear that you were able to find a solution!

This info could be interesting for @Sevitas

Sevitas commented 2 years ago

Hi, we have made some improvements in the latest version of the Generators SDK, renaming the parameter --contentmanagementapi to --managementapi was one of them. If you need to generate the Management models, you need to use the new parameter, otherwise the default value will be used and Delivery models will be generated. We have created a feature request which should clear up the confusion. What do you think about it @twadevs?

twadevs commented 2 years ago

Thanks @Sevitas , sounds good. I think an error message would be great.