gpt4 book ai didi

azure - 我可以使用 Graph API 和 ADAL 库将 Azure Workplace 加入设备状态更改为合规吗

转载 作者:行者123 更新时间:2023-12-03 04:41:54 32 4
gpt4 key购买 nike

我正在尝试使用以下 API。 https://developer.microsoft.com/en-us/graph/docs/api-reference/v1.0/api/intune_deviceconfig_devicecompliancedevicestatus_update

您能解释一下此 API 中使用的路径变量吗?设备合规性策略 IDdeviceComplianceDeviceStatusId。

这是我的示例代码

  private static String patchComplianceCheckh(String accessToken) throws IOException {


String s1 = "https://graph.microsoft.com/v1.0/deviceManagement/deviceCompliancePolicies/71889b5c-8ea2-473c-9a95-23bcd0e15ae8/deviceStatuses/2fa7d8fe-f410-4872-9991-87092a6ac070";

URL url = new URL(s1);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestProperty("X-HTTP-Method-Override", "PATCH");
conn.setRequestMethod("POST");
conn.setRequestProperty("Authorization", "Bearer " + accessToken);
conn.setRequestProperty("Authorization", "Bearer " + accessToken);
// conn.setRequestProperty("Accept","application/json");
conn.setRequestProperty("Content-type","application/json");
int httpResponseCode = conn.getResponseCode();
System.out.println("httpResponseCode " + httpResponseCode);
if(httpResponseCode == 200) {
BufferedReader in = null;
StringBuilder response;
try{
in = new BufferedReader(
new InputStreamReader(conn.getInputStream()));
String inputLine;
response = new StringBuilder();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
} finally {
in.close();
}
System.out.println(response.toString());
return response.toString();
} else {
return String.format("Connection returned HTTP code: %s with message: %s",
httpResponseCode, conn.getResponseMessage());
}
}

如何将请求参数发送到请求?我收到 411 HTTP 错误代码。

最佳答案

DeviceCompliancePolicyId

执行以下调用 -

GET https://graph.microsoft.com/v1.0/deviceManagement/deviceCompliancePolicies

下面响应中返回的 ID ("id": "4214b716-b716-4214-16b7-144216b71442") 是 DeviceCompliancePolicyId-

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 393

{
"value": [
{
"@odata.type": "#microsoft.graph.deviceCompliancePolicy",
"id": "4214b716-b716-4214-16b7-144216b71442",
"createdDateTime": "2017-01-01T00:02:43.5775965-08:00",
"description": "Description value",
"lastModifiedDateTime": "2017-01-01T00:00:35.1329464-08:00",
"displayName": "Display Name value",
"version": 7
}
]
}

DeviceComplianceDeviceStatusId

执行以下调用 -

GET https://graph.microsoft.com/v1.0/deviceManagement/deviceCompliancePolicies/{deviceCompliancePolicyId}/deviceStatuses

下面响应中返回的 ID ("id": "c6c78124-8124-c6c7-2481-c7c62481c7c6") 是 DeviceComplianceDeviceStatusId-

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 544

{
"value": [
{
"@odata.type": "#microsoft.graph.deviceComplianceDeviceStatus",
"id": "c6c78124-8124-c6c7-2481-c7c62481c7c6",
"deviceDisplayName": "Device Display Name value",
"userName": "User Name value",
"deviceModel": "Device Model value",
"complianceGracePeriodExpirationDateTime": "2016-12-31T23:56:44.951111-08:00",
"status": "notApplicable",
"lastReportedDateTime": "2017-01-01T00:00:17.7769392-08:00",
"userPrincipalName": "User Principal Name value"
}
]
}

关于azure - 我可以使用 Graph API 和 ADAL 库将 Azure Workplace 加入设备状态更改为合规吗,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52285308/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com