使用PowerShell的Outlook Online日历REST API(Office 365)

时间:2018-06-28 15:57:58

标签: powershell office365

我正在尝试通过Powershell和Office365 REST API在Office365中创建日历事件,但是我收到一个错误,并且我不知道如何解决它。这是我的ps代码:

$uri = https://outlook.office.com/api/v2.0/me/calendars/{0}/events" -f "ID_OF_THE_CALENDAR"
$body = @{
    Subject = "Arbitrary Event";
    Body = @{
        ContentType = "HTML";
        Content = "Text to describe the event"
};
Start = @{
    DateTime = "2018-06-27T16:00:00";
    TimeZone = "Eastern Standard Time";
    };
    End = @{
        DateTime = "2018-06-27T17:00:00";
        TimeZone = "Eastern Standard Time";
    };
    Attendees = @();
} | ConvertTo-Json -Depth 5;
Invoke-RestMethod `
    -Uri $uri
    -Body $body
    -Method Post
    -ContentType "application/json";

我已经尝试了-method POST和PUT两种方法,并且在两种情况下都收到错误消息:“ Invoke-RestMethod:无法发送具有此动词类型的content-body。”我已经阅读了许多应该在其中运行的示例,但它们可能是针对较早版本的api的。如果有人可以通过PowerShell提出修复建议或其他更新Office365日历的方法,请告诉我。

谢谢。

0 个答案:

没有答案
相关问题