如何通过OTRS REST URL获取多个故障单ID的故障单详细信息

时间:2017-11-16 07:46:52

标签: rest web-services rest-client otrs advanced-rest-client

目前我使用此URL作为单一票证ID:http:///otrs/nph-genericinterface.pl/Webservice/GenericTicketConnectorREST/Ticket/2020?UserLogin = abc& Password = abc123& DynamicFields = 1

如何将多个故障单ID传递到此URL ..

2 个答案:

答案 0 :(得分:1)

你不能。您应该在代码中使用循环,并为每个TicketID调用Web服务。

答案 1 :(得分:0)

以下是带有票证获取通用接口的otrs6 rest api的示例

<?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);


}


?>