I want to know how to get and link the ticket to Configuration item through SOAP or REST Webservice. I have imported this Restfull Web service in admin console and successfully created and getting ticket information using this url http://XXX.XXX.XXX.XXX/otrs/nph-genericinterface.pl/Webservice/GenericTicketConnectorREST/Ticket/1.
but the problem is the linked config item information is not coming when i get the ticket information.
i did lots of search on google found that ticket can be linked to Config Item through OTRS GUI and in AgentTicketzoom page it will show, i want this to be done through web service. can any one help me in this problem or suggest some doc on how to create web service to get linked object information from ticket.
Updated#1
i added web controller to my existing Ticket connector successfully. the url is http://XXX.XXX.XXX.XXX/otrs/nph-genericinterface.pl/Webservice/GenericTicketConnectorRest/LinkObject with POST Call.but i am getting this error
{"faultcode":"Server","faultstring":"Got no ConfigObject!"}
i checked the initial parameters also
$VAR1 = { 'Password' => '1234567', 'RequestMethod' => 'POST','SourceKey' => '1', 'SourceObject' => 'Ticket', 'State' => 'valid', 'TargetKey' => '2', 'TargetObject' => 'ITSMConfigItem', 'Type' => 'ParentChild', 'UserID' => '1', 'UserLogin' => 'XXXXX.XXXX@XXXX.com'};
$VAR1 = { 'ErrorMessage' => 'Got no ConfigObject!', 'Success' => 0};
Yes, the ticket can be linked to a configItem via a GUI and it can be done via a Webservice.
First of all you should write a new Generic Interface Connector operation, which will handle method LinkAdd from LinkObject Class ( APIdoc )
Then create and register new operations via a new XML file, like this:
FILE NAME: GenericInterfaceLinkObjectConnector.xml
After that you can publish a new provider WebService from OTRS GUI, where a newly created connector is used.
Make sure, that you pass all the needed parameters for the method!!!
UPDATE:
Please read this Document to understand how Generic Interface is built and then please add a new Connector ( LinkObject )
To register the connector and its operation - place XML file in /Kernel/Config/Files/...
Then go to Sysconfig -> GenericInterface -> GenericInterface::Operation::ModuleRegistration and set a tick next to the GenericInterface::Operation::Module###LinkObject::LinkAdd and save changes
Afterwards add this Connector file to /Custom/Kernel/GenericInterface/Operation/LinkObject/LinkAdd.pm
And afterwards it should appear and can be used from the Admin -> WebServices -> Available Operations dropdown and of course can be used as a webservice.
A PHP usage example can be seen below:
In case of errors - enable debugging, review the System Log and check all the initial settings of OTRS
Good Luck!
UPDATE #2
To register a webservice - press the button Add new webservice, name it as you want it and set the following settings ( Select the LinkAdd Operation ) and save it
UPDATE #3
Here is an updated module file for OTRS 5
After lot of work, i've found the solution to made it by POST REST call. My main trouble was about creating LinkObject with right %Param. So, i've implement direct code to aquire right call LinkAdd. Mainly, Artjoman provide the way. But i catch some errors on it, so here is another perl module in OTRS_HOME/Custom/Kernel/GenericInterface/Operation/LinkObject/LinkAdd.pm:
So, making POST call to (http://otrs_host/otrs/nph-genericinterface.pl/Webservice/GenericTicketConnectorREST/LinkAdd?UserLogin=login&Password=password) with json
{"SourceObject":"Ticket","SourceKey":"7","TargetObject":"ITSMConfigItem","TargetKey":"1","Type":"DependsOn","State":"Valid","UserID":"1"}
will create a link between Ticket and ITSMConfigItem (not a computer, hardware and so on.) I think, this simple and quite rude solution will help to understand how to add a full-api operations to your REST otrs with a better(but working) way.