microsoftgraph / microsoftgraph/msgraph-sdk-python
Create managedDevice example not working
还没有人认领这个 Issue。
- 主要语言
- 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_
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从 Microsoft Graph managedDevice 创建文档 URL 中的 Python 示例开始,并将其与错误中显示的 SDK 请求路径进行比较。检查该操作是否受 endpoint 支持,以及是否应更正示例或将其标记为不支持;完成的标准是,文档中的 Python 场景不再产生所报告的 400 错误,或明确说明该限制。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- python
- 领域
- api, documentation
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 38/100