我需要使用 PowerShell 脚本来创建 Zendesk 票证。但我不断从 API 收到以下错误:
The remote server returned an error: (422) Unprocessable Entity.
下面是脚本:
$username="username";
$password="password";
$request = [System.Net.WebRequest]::Create('https://domain.zendesk.com/api/v2/tickets.json');
$request.Method = "POST";
$request.ContentType = "Content-Type: application/json";
$request.Credentials = New-Object System.Net.NetworkCredential($username, $password)
$bytes = [System.Text.Encoding]::ASCII.GetBytes('{"ticket":{"subject":"My printer is on fire!", "comment": { "body": "The smoke is very colorful." }}}');
$requestStream = $request.GetRequestStream();
$requestStream.Write( $bytes, 0, $bytes.Length );
$requestStream.Close();
$response = $request.GetResponse();
提前感谢您的任何见解,因为我大部分时间都在用头撞墙。