KindeK
Kinde4mo ago
7 replies
Joel

.NET Get Users JSON Serialization Error

When using the .NET SDK, I'm trying to use an M2M flow to get user information. The M2M application has the get:users scope for the Management API and I've set up a simple .NET test app to retrieve and print users based on the .NET SDK documentation (https://docs.kinde.com/developer-tools/sdks/backend/dotnet-sdk/#configure-api-client) but it looks like there is a JSON serialization error for the response coming back. Am I doing something wrong in setting up this call to Management API?

Exception has occurred: CLR/Kinde.Api.Client.ApiException
An exception of type 'Kinde.Api.Client.ApiException' occurred in System.Private.CoreLib.dll but was not handled in user code: 'Cannot deserialize the current JSON array (e.g. [1,2,3]) into type 'Kinde.Api.Client.Option1[System.Collections.Generic.List1[Kinde.Api.Model.UsersResponseUsersInner]]' because the type requires a JSON object (e.g. {"name":"value"}) to deserialize correctly.
To fix this error either change the JSON to a JSON object (e.g. {"name":"value"}) or change the deserialized type to an array or a type that implements a collection interface (e.g. ICollection, IList) like List<T> that can be deserialized from a JSON array. JsonArrayAttribute can also be added to the type to force it to deserialize from a JSON array.
Path 'users', line 1, position 25.'
at Kinde.Api.Client.CustomJsonCodec.<Deserialize>d7.MoveNext()
at Kinde.Api.Client.CustomJsonCodec.<Deserialize>d
61.MoveNext() at Kinde.Api.Client.ApiClient.<ExecAsync>d__221.MoveNext()
at Kinde.Api.Api.UsersApi.<GetUsersWithHttpInfoAsync>d65.MoveNext()
at Kinde.Api.Api.UsersApi.<GetUsersAsync>d
64.MoveNext()
at Program.<<Main>$>d__0.MoveNext() in c:\repos\chill-warrior\kinde-test\Program.cs:line 17
image.png
Kinde docs
Guide to using the Kinde .NET SDK for integrating with the Management API, including installation, configuration, and API calls for user and organization management.
.NET SDK
Was this page helpful?