Re: Powershell Syntax REST API OTRS

Roy Kaldung <[email protected]> Fri, 9 Aug 2019 13:34:33 +0200
Newsgroups gmane.comp.otsr.user.german
Message-ID <[email protected]>
Hallo Thomas,

> On Aug 9, 2019, at 1:24 PM, <[email protected]> <[email protected]> wrote:
> 
> Hat mir jemand ein funktionierendes Beispiel?

Klar, allerdings mit Session statt Username/Passwort. Sollte aber kein Problem sein.


$headers = @{}
$headers.Add("Accept", "application/json")
$headers.Add("Content-Type", "application/json”)

$TicketData = @{
	SessionID = $SessionID

	Ticket = @{
		Title = 'Tickettitle'
		QueueID = 1
		State = 'new'
		Priority = '3 normal'
		CustomerUser = '[email protected]'
		Type = 'Unclassified'
        }
        Article = @{
                Subject = 'The article subject'
                Body    = 'Test'
                ContentType = 'text/plain; charset=utf8'
                MimeType = 'text/plain'
                Charset = 'utf8'
        }
}

$json = $TicketData | ConvertTo-Json
$Result = Invoke-RestMethod -Method Post -Headers $Headers -ContentType 'application/json' -Uri "$uri/Ticket" -Body $json
Write-Host Created ticket $Result.TicketNumber


- Roy

-- 
Roy Kaldung
---------------------------------------------------------------------
OTRS mailing list: otrs-de - Webpage: http://otrs.org/
Archive: http://lists.otrs.org/pipermail/otrs-de
To unsubscribe: http://lists.otrs.org/mailman/listinfo/otrs-de