Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing Enumeration Members #2735

Open
jbh999 opened this issue Nov 7, 2024 · 4 comments
Open

Missing Enumeration Members #2735

jbh999 opened this issue Nov 7, 2024 · 4 comments
Labels

Comments

@jbh999
Copy link

jbh999 commented Nov 7, 2024

Describe the bug

Deserializing the JSON response from the getManagedDevice API endpoint (no issue here) and then casting it into a ManagedDevice object throws an exception.


The JSON response returned from the API includes:

"managementAgent": "intuneAosp"
"deviceEnrollmentType": "androidAOSPUserOwnedDeviceEnrollment"

Neither of these values have a member in the associated enumerations contained in the ManagedDevice class:
ManagementAgentType enumeration does not have an intuneAosp member
DeviceEnrollmentType enumeration does not have an androidAOSPUserOwnedDeviceEnrollment member

Casting the deserialized response from the getManagedDevice API results in the following exception:

Newtonsoft.Json.JsonSerializationException: Error converting value "intuneAosp" to type 'System.Nullable`1[Microsoft.Graph.ManagementAgentType]'. Path '[1].managementAgent'.
---> System.ArgumentException: Requested value 'intuneAosp' was not found.

Expected behavior

Ability to deserialize the JSON response from getManagedDevice API endpoint and cast it into a ManagedDevice object

How to reproduce

  1. Enroll a DigiLens (Set up Intune enrollment for Android (AOSP) corporate-owned user-associated devices)

  2. Call the getManagedDevice API

  3. Review the JSON (API returns success and a valid JSON response)
    "managementAgent": "intuneAosp"
    "deviceEnrollmentType": "androidAOSPUserOwnedDeviceEnrollment"

  4. Deserializing the JSON response and casting it into a ManagedDevice object results in the exception

SDK Version

No response

Latest version known to work for scenario above?

Never worked

Known Workarounds

None that I know of

Debug output

Click to expand log ```
</details>


### Configuration

Windows 11 x64

Not related to any specific configuration

### Other information

• [ManagementAgentType enumeration](https://github.com/microsoftgraph/msgraph-sdk-dotnet/blob/c75439214c6752d0dff406ab4b0905a4369a7b5d/src/Microsoft.Graph/Generated/Models/ManagementAgentType.cs) requires an `intuneAosp` member
• [DeviceEnrollmentType enumeration](https://github.com/microsoftgraph/msgraph-sdk-dotnet/blob/c75439214c6752d0dff406ab4b0905a4369a7b5d/src/Microsoft.Graph/Generated/Models/DeviceEnrollmentType.cs) requires an `androidAOSPUserOwnedDeviceEnrollment` member
@jbh999 jbh999 added status:waiting-for-triage An issue that is yet to be reviewed or assigned type:bug A broken experience labels Nov 7, 2024
@andrueastman
Copy link
Member

andrueastman commented Nov 8, 2024

Thanks for raising this @jbh999

Any chance you can share a code sample of how you are deserializing the response as well as the SDK version you are using? I believe without a relevant converter like this one, Newtonsoft.Json will not support dowcasting out of the box.
https://github.com/microsoftgraph/msgraph-sdk-dotnet-core/blob/e7ab26c8863b9ab0ca450ca95959d231205fad6a/src/Microsoft.Graph.Core/Serialization/DerivedTypeConverter.cs#L59

@andrueastman andrueastman added status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close and removed status:waiting-for-triage An issue that is yet to be reviewed or assigned labels Nov 8, 2024
@jbh999
Copy link
Author

jbh999 commented Nov 9, 2024

I am using Newtonsoft (as visible in the exception documented in Describe the bug section above).

The code (deserializing JSON and casting to a ManagedDevice object) has been working for the past couple of years for all of our other enrolled device types.

The basic code used to deserialize JSON and cast into a ManagedDevice object ...

var response = await httpClient.GetAsync(apiUrl);
var responseContent = response.Content.ReadAsStringAsync().GetAwaiter().GetResult();
JObject result = JsonConvert.DeserializeObject(responseContent) as JObject;
var completeContent = new StringContent(JsonConvert.SerializeObject((JArray)result["value"], Formatting.None));
var responseContentComplete = await completeContent.ReadAsStringAsync();
JArray? devices = JsonConvert.DeserializeObject(responseContentComplete) as JArray;
devicesToReturn = devices.ToObject<ManagedDevice[]>().ToList<ManagedDevice>();

The issue is that the SDK (any version) does not support the enumeration members in the API response
ManagementAgentType enumeration does not have an intuneAosp member
DeviceEnrollmentType enumeration does not have an androidAOSPUserOwnedDeviceEnrollment member

@microsoft-github-policy-service microsoft-github-policy-service bot added Needs: Attention 👋 and removed status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close labels Nov 9, 2024
@jbh999
Copy link
Author

jbh999 commented Dec 3, 2024

I just noticed that these are listed in the documentation for the Beta MS Graph REST API

Are there currently any plans to have the beta enumeration members promoted to v1.0 and incorporated into the code?

@olivermue
Copy link

Based on my experience: If you want to use the Graph API to do anything in case of device management, then switch to the beta endpoint. There is plenty of stuff that is simply not available or behaves differently in v1 on a HTTP level (so no blame for the SDK). Also if you look into the network tab when browsing https://intune.microsoft.com you'll see that they do everything at the beta endpoint.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants