我試圖通過使用Powershell的REST-API訪問Exchange 2016 CU5環境的日曆。 GET方法正常工作沒有錯誤,但現在我試圖用POST方法編寫日曆事件,它不會工作。這裏是我的代碼:Microsoft Exchange REST API使用Powershell的POST編寫日曆事件
$cred = Get-Credential
$url = "https://myexchangeserver.de/api/v2.0/me/events"
$content = "application/json"
$body = "{
""Event"": {
""Subject"": ""Testtermin REST"",
""Body"": {
""ContentType"": ""HTML"",
""Content"":""Testtermin REST""
},
""Start"": {
""DateTime"": ""2017-10-10T16:00:00"",
""TimeZone"": ""Europe/Berlin""
},
""End"": {
""DateTime"": ""2017-10-10T16:30:00"",
""TimeZone"": ""Europe/Berlin""
},
""Attendees"": [
{
""EmailAddress"": {
""Address"": ""[email protected]"",
""Name"": ""Otto Outlooktest""
},
""Type"": ""Required""
}
]
}}"
Invoke-RestMethod -Uri $url -Method Post -Credential $cred -ContentType $content -Body $body
我把它放到.ps1文件中並在我的Exchange命令行管理程序中執行它。
它打開一個彈出窗口讓我輸入我的憑證,但之後我總是收到一條錯誤消息「400無效請求」。
我已經嘗試了幾個着作,但總是一樣的。
任何人都知道什麼是錯的?
問候,邁克爾
你試過沒有憑據運行它嗎?例如,通過以Exchange管理員身份或從運行身份窗口登錄?這樣我們可以消除可能性 –