im_mangesh
im_mangesh

Reputation: 175

how to get ticket details of multiple ticket IDs through OTRS REST URL

Currently i used this URL for single ticket ID: http:///otrs/nph-genericinterface.pl/Webservice/GenericTicketConnectorREST/Ticket/2020?UserLogin=abc&Password=abc123&DynamicFields=1

How can i pass multiple ticket IDs into this URL..

Upvotes: 3

Views: 2285

Answers (2)

Gaurav Jha
Gaurav Jha

Reputation: 19

Here is the example of otrs6 rest api with generic interface for ticketget

<?php

require_once 'otrs6composer/vendor/autoload.php';

Unirest\Request::defaultHeader("Accept", "application/json");
Unirest\Request::defaultHeader("Content-Type", "application/json");
Unirest\Request::verifyPeer(true);

function otrs_ticket_detail_listing($ticket) {

$title = "";
$state = "";
$type = "";
$queue = "";
$output = "";

$TicketNr = $ticket;
$BaseURL2 = 'http://10.247.142.10/otrs/nph-genericinterface.pl/Webservice/TicketConGeneric/TicketGet';
$BaseURL1 = 'http://10.247.142.10/otrs/nph-genericinterface.pl/Webservice/TicketConGeneric/Session/SessionCreate';
$headers = [];
$body = json_encode(
    [
        "UserLogin" => "root@localhost",
        "Password"  => "nic123",
    ]
);

/**
 * SessionCreate
 *
 * http://doc.otrs.com/doc/api/otrs/stable/Perl/Kernel/GenericInterface/Operation/Session/SessionCreate.pm.html
 */
$response = Unirest\Request::post($BaseURL1, $headers, $body);

if (!$response->body->SessionID) {
    print "No SessionID returnd \n";
    exit(1);
}
$SessionID = $response->body->SessionID;



/**
 * TicketGet
 *
 * http://doc.otrs.com/doc/api/otrs/stable/Perl/Kernel/GenericInterface/Operation/Ticket/TicketGet.pm.html
 */
$param = [
    'SessionID' => $SessionID,
];
$ArticleGet = Unirest\Request::get($BaseURL2."/".$TicketNr, $headers, $param);



return $ArticleGet;
//var_dump($response);


}


?>

Upvotes: 0

MichielB
MichielB

Reputation: 4294

You can't. You should just use a loop in your code and make a call to the web service for each TicketID.

Upvotes: 1

Related Questions