Sujan Shrestha
Sujan Shrestha

Reputation: 1040

DIsplay all otrs ticket using soap api

How can i display all the otrs tickets using a soap api. Individual ticket can be displayed by passing ticket id in url like this:

$url = "https://url/otrs/rpc.pl"; //// URL for OTRS server
$username = "username"; //// SOAP username set in sysconfig
$password = "password"; //// SOAP password set in sysconfig
$TicketID = $_GET['id'];
  //////// Initialize new client session ////////
    $client = new SoapClient(
        null,
        array(
            'location' => $url,
            'uri' => "Core",
            'trace' => 1,
            'login' => $username,
            'password' => $password,
            'style' => SOAP_RPC,
            'use' => SOAP_ENCODED
        )
    );
//////// Create and send the SOAP Function Call ////////
    $sql =
    $TicketDetails = $client->__soapCall("Dispatch",
        array($username, $password,
            "TicketObject", "TicketGet",
            "TicketID", $TicketID,
        ));
 $ticketInfo = array();
    $i = 0;

    foreach ($TicketDetails as $name => $value){ //// explode the xml response
        if (false !== strpos($name, "s-gensym")){

            $temp[$i] = $value;
            $v = $temp[$i - 1];
            if($i % 2 != 0){
                $ticketInfo[$v] = $value;
            }
            $i++;
        }
    }
 var_dump($ticketInfo);
    exit();

How can i display all the tickets using api?????

Upvotes: 3

Views: 4315

Answers (1)

MichielB
MichielB

Reputation: 4294

Use the TicketSearch API call in order to retrieve a list of Ticket IDs. Then feed this list to TicketGet as you already showed in order to retrieve ticket details.

Upvotes: 2

Related Questions