我正在尝试使用 powershell 向 O365 'Incoming Webhook' 发布一条简单的消息。这是代码:
$url = 'https://outlook.office365.com/webhook/.......'
$body = @"
{
"text": "Hello World!"
"title": "Today"
}
"@
Invoke-RestMethod -Uri $url -Method Post -Body $body -ContentType "application/json"
但是得到这个错误:
PSMessageDetails :
Exception : System.Net.WebException: The remote server returned an error: (404) Not Found.
at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.GetResponse(WebRequest request)
at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.ProcessRecord()
TargetObject : System.Net.HttpWebRequest
CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand
ErrorDetails : Invalid webhook request
InvocationInfo : System.Management.Automation.InvocationInfo
ScriptStackTrace : at <ScriptBlock>, <No file>: line 10
PipelineIterationInfo : {}
如果我省略-Contentype
参数,我会收到此错误:
Microsoft.IdentityModel.Clients.ActiveDirectory.AdalServiceException: AADSTS90002: Requested tenant identifier '00000000-0000-0000-0000-000000000000' is not valid. Tenant identifiers may not be an empty GUID.
Trace ID: c4b77459-3915-475e-8125-fa2db9fd11e8
Correlation ID: 0ba64202-db52-4a96-8f44-a87b7f009170
Timestamp: 2016-03-27 07:48:02Z
有人知道如何让它工作吗?