我有以下PowerShell脚本,它在Office 365组日历上添加事件。当我运行下面的脚本时,它只会添加第一个事件,而不会添加第二个事件。而且没有错误。我在剧本上错过了什么吗?任何对此的帮助都将不胜感激,谢谢。
$json = @"
{
"subject": "Event1",
"start": {
"timeZone": "UTC",
"dateTime": "2023-06-10T08:00"
},
"end": {
"timeZone": "UTC",
"dateTime": "2023-06-10T09:00"
}
},
{
"subject": "Event2",
"start": {
"timeZone": "UTC",
"dateTime": "2023-06-11T08:00"
},
"end": {
"timeZone": "UTC",
"dateTime": "2023-06-11T09:00"
}
}
"@
$apiUrl = "https://graph.microsoft.com/v1.0/groups/xxxx-xxxx-xxxx-xxx/events"
Invoke-RestMethod -Headers @{Authorization = "Bearer $($Tokenresponse.access_token)"} -Uri $apiUrl -Method Post -ContentType "application/json" -Body $json
3条答案
按热度按时间ctrmrzij1#
您不能使用Graph API一次创建多个事件,要创建多个事件,您必须使用批处理,请参阅此link了解更多信息:
请参见此处的示例:
idfiyjo82#
端点
https://graph.microsoft.com/v1.0/groups/xxxx-xxxx-xxxx-xxx/events
只允许添加一个事件。第二个事件被忽略。使用batch端点
wlwcrazw3#
我收到以下错误
相同的json从https://developer.microsoft.com/en-us/graph/graph-explorer工作正常