TicketSearch call from OTRS Webservice

Moderator: crythias

Post Reply
mohsinkhan009
OTRS newbie
Posts: 64
Joined: 02 Sep 2015, 08:47
OTRS Version?: OTRS-Rel-5

TicketSearch call from OTRS Webservice

Post by mohsinkhan009 »

Hi All,
Need to understand how do we need to pass the parameter for TicketSearch when we are calling the OTRS webservice

http://x.x.x.x/otrs/nph-genericinterfac ... cketSearch

root
Moderator
Posts: 2381
Joined: 18 Dec 2007, 12:23
OTRS Version?: 4/5/6
Real Name: Roy Kaldung
Company: Znuny Inc.
Contact:

Re: TicketSearch call from OTRS Webservice

Post by root »

I assume you talk about the default REST web service. Try to add the parameters (see http://doc.otrs.com/doc/api/otrs/stable ... ch.pm.html) to the URL.
OTRS 5/6 CentOS / RHEL / Debian / SLES / MySQL / PostgreSQL / Oracle / OpenLDAP / Active Directory / SSO

Do you need professional services for the ((OTRS)) Community Edition? Check out https://www.znuny.com/

mohsinkhan009
OTRS newbie
Posts: 64
Joined: 02 Sep 2015, 08:47
OTRS Version?: OTRS-Rel-5

Re: TicketSearch call from OTRS Webservice

Post by mohsinkhan009 »

I tired with the below code mention on the OTRS webservice document here I have change the operation as TicketSearch and also the OTRS_FQDN

use strict;
use warnings;

# use ../ as lib location
use File::Basename;
use FindBin qw($RealBin);
use lib dirname($RealBin);

use SOAP::Lite;
use Data::Dumper;

# ---
# Variables to be defined.

# this is the URL for the web service
# the format is
# <HTTP_TYPE>:://<OTRS_FQDN>/nph-genericinterface.pl/Webservice/<WEB_SERVICE_NAME>
# or
# <HTTP_TYPE>:://<OTRS_FQDN>/nph-genericinterface.pl/WebserviceID/<WEB_SERVICE_ID>
my $URL = 'http://localhost/otrs/nph-genericinterf ... tConnector';

# this name space should match the specified name space in the SOAP transport for the web service.
my $NameSpace = 'http://www.otrs.org/TicketConnector/';

# this is operation to execute, it could be TicketCreate, TicketUpdate, TicketGet, TicketSearch
# or SessionCreate. and they must to be defined in the web service.
my $Operation = 'TicketSearch';

# this variable is used to store all the parameters to be included on a request in XML format. Each
# operation has a determined set of mandatory and non mandatory parameters to work correctly. Please
# check the OTRS Admin Manual in order to get a complete list of parameters.
my $XMLData = '
<UserLogin>some user login</UserLogin>
<Password>some password</Password>
<Ticket>
<TicketNumber>2016101243001044</TicketNumber>
</Ticket>
';

# ---

# create a SOAP::Lite data structure from the provided XML data structure.
my $SOAPData = SOAP::Data
->type( 'xml' => $XMLData );

my $SOAPObject = SOAP::Lite
->uri($NameSpace)
->proxy($URL)
->$Operation($SOAPData);

# check for a fault in the soap code.
if ( $SOAPObject->fault ) {
print $SOAPObject->faultcode, " ", $SOAPObject->faultstring, "\n";
}

# otherwise print the results.
else {

# get the XML response part from the SOAP message.
my $XMLResponse = $SOAPObject->context()->transport()->proxy()->http_response()->content();

# deserialize response (convert it into a perl structure).
my $Deserialized = eval {
SOAP::Deserializer->deserialize($XMLResponse);
};

# remove all the headers and other not needed parts of the SOAP message.
my $Body = $Deserialized->body();

# just output relevant data and no the operation name key (like TicketCreateResponse).
for my $ResponseKey ( keys %{$Body} ) {
print Dumper( $Body->{$ResponseKey} );
}
}


But I am not getting the proper result below is the result which I am getting


$VAR1 = '<?xml version="1.0" encoding="UTF-8"?><soap:Envelope soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instan ... chResponse xmlns="http://schemas.xmlsoap.org/soap/envelop ... p:Envelope>';

root
Moderator
Posts: 2381
Joined: 18 Dec 2007, 12:23
OTRS Version?: 4/5/6
Real Name: Roy Kaldung
Company: Znuny Inc.
Contact:

Re: TicketSearch call from OTRS Webservice

Post by root »

Well, I never touched the SOAP connector, sorry.

Did you tried this payload?

Code: Select all

<UserLogin>some user login</UserLogin>
<Password>some password</Password>
<TicketNumber>2016101243001044</TicketNumber> 
OTRS 5/6 CentOS / RHEL / Debian / SLES / MySQL / PostgreSQL / Oracle / OpenLDAP / Active Directory / SSO

Do you need professional services for the ((OTRS)) Community Edition? Check out https://www.znuny.com/

mohsinkhan009
OTRS newbie
Posts: 64
Joined: 02 Sep 2015, 08:47
OTRS Version?: OTRS-Rel-5

Re: TicketSearch call from OTRS Webservice

Post by mohsinkhan009 »

Yes I have provide the username and passord

mohsinkhan009
OTRS newbie
Posts: 64
Joined: 02 Sep 2015, 08:47
OTRS Version?: OTRS-Rel-5

Re: TicketSearch call from OTRS Webservice

Post by mohsinkhan009 »

Can some one help as I am not getting a specific Ticket ID when search ticketNumber

root
Moderator
Posts: 2381
Joined: 18 Dec 2007, 12:23
OTRS Version?: 4/5/6
Real Name: Roy Kaldung
Company: Znuny Inc.
Contact:

Re: TicketSearch call from OTRS Webservice

Post by root »

mohsinkhan009 wrote:Yes I have provide the username and passord
But you have enclosed TicketNumber by <Ticket> Die you tried it without?
OTRS 5/6 CentOS / RHEL / Debian / SLES / MySQL / PostgreSQL / Oracle / OpenLDAP / Active Directory / SSO

Do you need professional services for the ((OTRS)) Community Edition? Check out https://www.znuny.com/

mohsinkhan009
OTRS newbie
Posts: 64
Joined: 02 Sep 2015, 08:47
OTRS Version?: OTRS-Rel-5

Re: TicketSearch call from OTRS Webservice

Post by mohsinkhan009 »

After doing some RnD found that TicketSearch return TicketID. we need to use TicketGet function to get all the ticket details against the search ticketID

Post Reply