microsoftgraph / microsoftgraph/msgraph-sdk-python

Create managedDevice example not working

未關閉
#731 3 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

priority:p1 type:bug
主要語言
Python
星號
630
分支
96
平均合併
15 小時 20 分鐘
30 天內合併 PR
3

描述

Describe the bug

In the SDK documentation for creating managed devices there is an example which does not work, I am not sure if this is a user error or a bug, maybe someone can help me here?

The example I am talking about is here, specifically the python version.
https://learn.microsoft.com/en-us/graph/api/intune-devices-manageddevice-create?view=graph-rest-1.0&tabs=python

I am getting a 400 Bad Request error when using the example. The client object itself is not the problem, it works for all other calls without issues, my application has the required API permissions, but this is not related to that either since the error shows up without any permissions anyways.

Expected behavior

Should create a managed device when calling device_management.managed_devices.post(device)

How to reproduce
import asyncio
from azure.identity.aio import ClientSecretCredential
from msgraph import GraphServiceClient
from kiota_abstractions.api_error import APIError
from msgraph.generated.models.managed_device import ManagedDevice
from msgraph.generated.models.managed_device_owner_type import ManagedDeviceOwnerType
from msgraph.generated.models.device_action_result import DeviceActionResult
from msgraph.generated.models.action_state import ActionState
from msgraph.generated.models.compliance_state import ComplianceState
from msgraph.generated.models.management_agent_type import ManagementAgentType
from msgraph.generated.models.device_enrollment_type import DeviceEnrollmentType
from msgraph.generated.models.device_registration_state import DeviceRegistrationState
from msgraph.generated.models.device_management_exchange_access_state import DeviceManagementExchangeAccessState
from msgraph.generated.models.device_management_exchange_access_state_reason import DeviceManagementExchangeAccessStateReason
from msgraph.generated.models.configuration_manager_client_enabled_features import ConfigurationManagerClientEnabledFeatures
from msgraph.generated.models.device_health_attestation_state import DeviceHealthAttestationState
from msgraph.generated.models.managed_device_partner_reported_health_state import ManagedDevicePartnerReportedHealthState

TENANT_ID = 'tenant id'
CLIENT_ID =  'client id'
CLIENT_SECRET =  'client secret'

async def main():
    credentials = ClientSecretCredential(TENANT_ID, CLIENT_ID, CLIENT_SECRET)
    scopes = ['https://graph.microsoft.com/.default']
    client = GraphServiceClient(credentials=credentials, scopes=scopes)

    device = ManagedDevice(
    	odata_type = "#microsoft.graph.managedDevice",
    	user_id = "User Id value",
    	device_name = "Device Name value",
    	managed_device_owner_type = ManagedDeviceOwnerType.Company,
    	device_action_results = [
    		DeviceActionResult(
    			odata_type = "microsoft.graph.deviceActionResult",
    			action_name = "Action Name value",
    			action_state = ActionState.Pending,
    			start_date_time = "2016-12-31T23:58:46.7156189-08:00",
    			last_updated_date_time = "2017-01-01T00:00:56.8321556-08:00",
    		),
    	],
    	enrolled_date_time = "2016-12-31T23:59:43.797191-08:00",
    	last_sync_date_time = "2017-01-01T00:02:49.3205976-08:00",
    	operating_system = "Operating System value",
    	compliance_state = ComplianceState.Compliant,
    	jail_broken = "Jail Broken value",
    	management_agent = ManagementAgentType.Mdm,
    	os_version = "Os Version value",
    	eas_activated = True,
    	eas_device_id = "Eas Device Id value",
    	eas_activation_date_time = "2016-12-31T23:59:43.4878784-08:00",
    	azure_a_d_registered = True,
    	device_enrollment_type = DeviceEnrollmentType.UserEnrollment,
    	activation_lock_bypass_code = "Activation Lock Bypass Code value",
    	email_address = "Email Address value",
    	azure_a_d_device_id = "Azure ADDevice Id value",
    	device_registration_state = DeviceRegistrationState.Registered,
    	device_category_display_name = "Device Category Display Name value",
    	is_supervised = True,
    	exchange_last_successful_sync_date_time = "2017-01-01T00:00:45.8803083-08:00",
    	exchange_access_state = DeviceManagementExchangeAccessState.Unknown,
    	exchange_access_state_reason = DeviceManagementExchangeAccessStateReason.Unknown,
    	remote_assistance_session_url = "https://example.com/remoteAssistanceSessionUrl/",
    	remote_assistance_session_error_details = "Remote Assistance Session Error Details value",
    	is_encrypted = True,
    	user_principal_name = "User Principal Name value",
    	model = "Model value",
    	manufacturer = "Manufacturer value",
    	imei = "Imei value",
    	compliance_grace_period_expiration_date_time = "2016-12-31T23:56:44.951111-08:00",
    	serial_number = "Serial Number value",
    	phone_number = "Phone Number value",
    	android_security_patch_level = "Android Security Patch Level value",
    	user_display_name = "User Display Name value",
    	configuration_manager_client_enabled_features = ConfigurationManagerClientEnabledFeatures(
    		odata_type = "microsoft.graph.configurationManagerClientEnabledFeatures",
    		inventory = True,
    		modern_apps = True,
    		resource_access = True,
    		device_configuration = True,
    		compliance_policy = True,
    		windows_update_for_business = True,
    	),
    	wi_fi_mac_address = "Wi Fi Mac Address value",
    	device_health_attestation_state = DeviceHealthAttestationState(
    		odata_type = "microsoft.graph.deviceHealthAttestationState",
    		last_update_date_time = "Last Update Date Time value",
    		content_namespace_url = "https://example.com/contentNamespaceUrl/",
    		device_health_attestation_status = "Device Health Attestation Status value",
    		content_version = "Content Version value",
    		issued_date_time = "2016-12-31T23:58:22.1231038-08:00",
    		attestation_identity_key = "Attestation Identity Key value",
    		reset_count = 10,
    		restart_count = 12,
    		data_excution_policy = "Data Excution Policy value",
    		bit_locker_status = "Bit Locker Status value",
    		boot_manager_version = "Boot Manager Version value",
    		code_integrity_check_version = "Code Integrity Check Version value",
    		secure_boot = "Secure Boot value",
    		boot_debugging = "Boot Debugging value",
    		operating_system_kernel_debugging = "Operating System Kernel Debugging value",
    		code_integrity = "Code Integrity value",
    		test_signing = "Test Signing value",
    		safe_mode = "Safe Mode value",
    		windows_p_e = "Windows PE value",
    		early_launch_anti_malware_driver_protection = "Early Launch Anti Malware Driver Protection value",
    		virtual_secure_mode = "Virtual Secure Mode value",
    		pcr_hash_algorithm = "Pcr Hash Algorithm value",
    		boot_app_security_version = "Boot App Security Version value",
    		boot_manager_security_version = "Boot Manager Security Version value",
    		tpm_version = "Tpm Version value",
    		pcr0 = "Pcr0 value",
    		secure_boot_configuration_policy_finger_print = "Secure Boot Configuration Policy Finger Print value",
    		code_integrity_policy = "Code Integrity Policy value",
    		boot_revision_list_info = "Boot Revision List Info value",
    		operating_system_rev_list_info = "Operating System Rev List Info value",
    		health_status_mismatch_info = "Health Status Mismatch Info value",
    		health_attestation_supported_status = "Health Attestation Supported Status value",
    	),
    	subscriber_carrier = "Subscriber Carrier value",
    	meid = "Meid value",
    	total_storage_space_in_bytes = 8,
    	free_storage_space_in_bytes = 7,
    	managed_device_name = "Managed Device Name value",
    	partner_reported_threat_state = ManagedDevicePartnerReportedHealthState.Activated,
    	require_user_enrollment_approval = True,
    	management_certificate_expiration_date = "2016-12-31T23:57:59.9789653-08:00",
    	iccid = "Iccid value",
    	udid = "Udid value",
    	notes = "Notes value",
    	ethernet_mac_address = "Ethernet Mac Address value",
    	physical_memory_in_bytes = 5,
    	enrollment_profile_name = "Enrollment Profile Name value",
    )

    result = await client.device_management.managed_devices.post(device)

if __name__ == "__main__":
    asyncio.run(main())
msgraph.generated.models.o_data_errors.o_data_error.ODataError: 
        APIError
        Code: 400
        message: None
        error: MainError(additional_data={}, code='No method match route template', details=None, inner_error=InnerError(additional_data={}, client_request_id='8e3ad6b2-4b54-49cf-bd46-1192c7f7b6a9', date=DateTime(2024, 5, 29, 11, 54, 43, tzinfo=Timezone('UTC')), odata_type=None, request_id='36aa37e2-67a9-4e30-9c57-bd46666afa6e'), message='No OData route exists that match template ~/singleton/navigation with http verb POST for request /DeviceFE/StatelessDeviceFEService/deviceManagement/managedDevices.', target=None)
SDK Version

No response

Latest version known to work for scenario above?

No response

Known Workarounds

No response

Debug output
Click to expand log ```
</details>


### Configuration

_No response_

### Other information

_No response_

貢獻指南

開啟貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

研究方向

從 Microsoft Graph managedDevice 建立文件 URL 中的 Python 範例開始,並將其與錯誤中顯示的 SDK 要求路徑進行比較。檢查該操作是否受 endpoint 支援,以及是否應修正範例或將其標記為不支援;完成的標準是,文件中的 Python 情境不再產生所回報的 400 錯誤,或清楚說明該限制。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
python
領域
api, documentation
Issue 類型
缺陷
難度
3/5
預估耗時
1-2 天
活躍度
停滯
描述清晰度
基本清楚
新手友好度
38/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。