Webservices TicketSearch Display OpenTickets via Powershell

Moderator: crythias

Post Reply
Klicker
Znuny newbie
Posts: 8
Joined: 20 Oct 2020, 16:06
Znuny Version: 7.21
Real Name: Tim Otto

Webservices TicketSearch Display OpenTickets via Powershell

Post by Klicker »

Hello,
is it possible to use the TicketSearch function to query all open tickets and to display the ticket numbers?
I get no error and no result. My user has all rights to all queues.

Ive tried the following:
Result: "HASH" should show the ticket number. *https://doc.otrs.com/doc/api/otrs/8.0/P ... ch.pm.html
Webservice Configuration: /TicketSearch, POST, HTTP::REST

Code: Select all

$uri = "https://otrs-test.de/otrs/nph-genericinterface.pl/Webservice/WebTest/TicketSearch"

$user = 'TEST'
$pass = 'TEST'

$pair = "$($user):$($pass)"

$encodedCreds = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes($pair))

$basicAuthValue = "Basic $encodedCreds"


$headers = @{
    Authorization = $basicAuthValue
}

$TicketData = @{
        UserLogin = "test"
        Password = "testnutzer"
        
        Ticket = @{
                QueueID = 5
                States = "new"
                Result = "HASH"
                 
                
             }                        

}

$json = $TicketData | ConvertTo-Json
$Result = Invoke-RestMethod  -Method Post -Headers $headers -ContentType 'application/json' -Uri $uri -Body $json 

Write-Host Created ticket $Result.TicketNumber

skullz
Znuny superhero
Posts: 618
Joined: 24 Feb 2012, 03:58
Znuny Version: LTS and Features
Real Name: Mo Azfar
Location: Kuala Lumpur, MY
Contact:

Re: Webservices TicketSearch Display OpenTickets via Powershell

Post by skullz »

Not sure on 7.0/8.0, however on OTRS CE 6.0x or LTS,

1. The docs is for API. Not for web services.

2. For web service,

TicketSearch connector will only return Ticket IDs.

Then u have to use TicketGet connector to get the ticket details (ticket number, etc) based on the TicketID above.
Klicker
Znuny newbie
Posts: 8
Joined: 20 Oct 2020, 16:06
Znuny Version: 7.21
Real Name: Tim Otto

Re: Webservices TicketSearch Display OpenTickets via Powershell

Post by Klicker »

But how do I get the TicketIDs of all new tickets with the TicketSearch Connector?
iam currently not getting a error or result.
jojo
Znuny guru
Posts: 15019
Joined: 26 Jan 2007, 14:50
Znuny Version: Git Master
Contact:

Re: Webservices TicketSearch Display OpenTickets via Powershell

Post by jojo »

in my testsystem this request work (GET)

https://testsystem/otrs/nph-genericinte ... teType=new


If I use PUT the request goes to: https://testsystem/otrs/nph-genericinte ... EST/Ticket
using hte following json payload

{
"UserLogin":"webservice",
"Password":"mySecretPassword",
"StateType": "new"
}

Please note that the usage of other methods like PUT need reconfiuration in the GenericInterface
"Production": OTRS™ 8, OTRS™ 7, STORM powered by OTRS
"Testing": ((OTRS Community Edition)) and git Master

Never change Defaults.pm! :: Blog
Professional Services:: http://www.otrs.com :: enjoy@otrs.com
Post Reply