Unable to convert Resource to anything with OktaClient.GetAsync<T>

I am trying to obtain Application Users using the Okta SDK for .NET. Snippet of my code is

OktaClient oktaClient = new OktaClient(new OktaClientConfiguration
                OktaDomain = "...",
                Token = "..."

var result = oktaClient.GetAsync<**AppUser**>("/api/v1/apps/.../users");

I would get the exception where the Okta.Sdk.Resource failed to parse as it is an array. I would try List but that would result in another error stating that it failed to convert from Resource to List.

How would I use this GetAsync? What would be T? Thanks in advance!

1 Like

I’m having issues calling GetAsync() as well. I can make calls like this:

public static async Task<Okta.Sdk.IUser> GetCurrentUser(OktaClient client)
    Okta.Sdk.IUser u = await client.GetAsync<Okta.Sdk.User>(new HttpRequest { Uri = "/api/v1/users/me" });
        return u;

But when I try to use List or IEnumerable I can’t get to anything that works:

public static async Task<IEnumerable<Okta.Sdk.IGroup>> GetUserGroups(OktaClient client, string identity)
    string uri = string.Format("/api/v1/users/{0}/groups", identity);
    IEnumerable<Okta.Sdk.IGroup> g = await client.GetAsync<IEnumerable<Okta.Sdk.IGroup>>(new HttpRequest { Uri = uri });
    return g;

Any help is appreciated!

I am also running into this problem. I am trying to make an API call to Okta that is not part of the .Net SDK implementation (specifically the “Linked Objects” API). The API calls return JSON array types, even if there is only one object in the response.

It seems like there is no way to return a List or Dictionary from GetAsync(). Any attempts to do so result in a “there is no implicit conversion to Okta.Sdk.Resource”, and using a generic var as the variable definition throws an exception of “Cannot deserialize the current JSON array (e.g. [1,2,3]) into type ‘System.Collections.Generic.IDictionary’”

Is there a function definition for GetAsync() that can process a JSON array response?

I just confirmed that simply executing this line of code:

await client.GetAsync(href: " /api/v1/users/ {id}/linkedObjects/{associated.name}");

generates an exception. So it appears to be an error in the GetAsync() function in that it cannot process the response if it is a JSON array.