Api | create ticket via powershell

initial question

Anyone did this successfully and minds to share an example?
I’m struggling a bit with it right now (done it without a sweat via php/bash).

cheers

Got it myself, mini example:

$apientry = "https://**MY-ZAMMAD-SERVER**/api/v1/tickets"
$apitoken = "**API-TOKEN**"

$headers = @{ "Authorization" = "Token $apitoken"}
$body = @{ 
    title="**TITLE**"
    group="**GROUPNAME**"
    customer="**CUSTOMER-LOGIN**"
    type="**TICKET-TYPE**" #Incident/Problem/Request for Change
    article=@{
        subject="**SUBJECT**"
        body="**BODY**"
        type="note"
        }    
    }

$response = Invoke-RestMethod -Uri $apientry -Body ($body|ConvertTo-Json) -ContentType 'application/json' -Headers $headers -Method POST

Ofc this is going to be enhanced with more attributes and probably made into a function etc. But that should be enough to get anyone who wants to do this via powershell going.

5 Likes

Wow this is great, thanks for sharing!

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.