OTRS – Web Services Descriptions and Examples

OTRS,Web Services,Web Stuff — Jeff Eske on March 5, 2013 at 4:47 pm

The OTRS ticketing system comes with some basic web service functions included by default.  I’ve already done a post about using web services to create a new ticket via TicketCreate(), as well as a post about retrieving an existing ticket via TicketGet().  I’ve also created a page to allow you to search for a ticket using the TicketSearch() function, but I haven’t posted anything about that yet.  I’ve also posted a code snippet that actually helped me considerably when I was troubleshooting exactly what was going on.

What I’d like to do here is just note some observations that I’ve made while messing around trying to figure all of this out.  Hopefully it will be of some use to someone.  As with everything on this site, the Disclaimer holds here to – all I can guarantee is that this stuff worked for me.  What I have listed below is what I’ve determined from trial-and-error, so take it with a grain of salt.  This is almost more to document it for myself than anyone else.

===============

TicketCreate()
Purpose:
Used to create new tickets object (duh!).  Generally, you’ll want to do an ArticleCreate() also, to add some useful information to the ticket.
Required Input Values: TypeID(integer), QueueID(integer), LockID(integer), PriorityID(integer), State(text), CustomerUser(text), OwnerID(integer), UserID(integer).
Optional, but Recommended: Title(text). The title is required, but it seems logical to add one.
Returns: TicketID(integer)

[code]
// PHP code sample for TicketCreate().  Adjust the values as necessary
$TicketID = $client->__soapCall(
 "Dispatch",array($username, $password,
 "TicketObject", "TicketCreate",
 "Title", "Some Title",
 "TypeID", some_typeID_number,
 "QueueID",  some_queueID_number,
 "LockID", 1,
 "PriorityID", some_priorityID_number,
 "State", "new",
 "CustomerUser", "some_user@your_organization",
 "OwnerID", some_ownerID_number,
 "UserID", some_userID_number,
 )
 );
[/code]

===============

ArticleCreate()
Purpose: Add an article to a ticket.  The TicketCreate() function basically just creates a “wrapper” for articles.  The articles provide the content.
Required Input Values: TicketID(integer), ArticleType(text), SenderType(text), HistoryType(text), HistoryComment(text), ContentType(text), UserID(integer)
Optional, but Recommended: From(text), Subject(text), Body(text), Loop(integer), AutoRepsonseType(text), OrigHeader(array)
Returns: ArticleID(integer)

[code]
// PHP code sample for ArticleCreate().  Adjust the values as necessary
$ArticleID = $client->__soapCall("Dispatch", 
array($username, $password,
"TicketObject", "ArticleCreate",
"TicketID", some_ticketID_to_add_article_to,
"ArticleType", "webrequest",
"SenderType", "customer",
"HistoryType", "WebRequestCustomer",
"HistoryComment", "created from PHP",
"From", "some_customer@your_organization",
"Subject", "Some Subject",
"ContentType", "text/plain; charset=ISO-8859-1",
"Body", "Some Article Body text",
"UserID", some_userID_number,
"Loop", 0,
"AutoResponseType", 'auto reply',
"OrigHeader", array(
'From' => 'some_customer@your_organization',
'To' =>  'some_customer@your_organization',
'Subject' => 'Some Subject.  Probably the subject from above',
'Body' => 'Some Body text.  Probably the body from above'
),
)
);
[/code]

===============

TicketGet() 
Required Input Values: TicketID(integer)
Returns: Array of Age(integer), PriorityID(integer)ServiceID(integer), Type(text), Responsible(text), StateID(integer), ResponsibleID(integer), ChangeBy(integer), EscalationTime(integer), Changed(date/time), OwnerID(integer), RealTillTimeNotUsed(integer), GroupID(integer), Owner(text), CustomerID(text), TypeID(integer), Created(date/time), Priority(text), UntilTime(integer), EscalationUpdateTime(integer), QueueID(integer), Queue(text), State(text), Title(text), FirstLock(date/time), CreateBy(integer), TicketID(integer), StateType(text), EscalationResponseTime(integer), UnlockTimeout(integer), EscalationSolutionTime(integer), LockID(integer), TicketNumber(integer), ArchiveFlag(text), CreateTimeUnix(unixtime), Lock(text), SLAID(integer), CustomerUserID(text)

[code]
// PHP code sample for TicketGet().  Adjust the values as necessary
$TicketDetails = $client->__soapCall("Dispatch", 
array($username, $password,
"TicketObject", "TicketGet",
"TicketID", some_ticketID_number,
"Extended", 1,
));
[/code]

===============

TicketSearch()
Required Input Values: CustomerUserID(text)
Returns: Array of TicketID(integer), TicketNumber(integer)

[code]
// PHP code sample for TicketSearch().  Adjust the values as necessary
$TicketDetails = $client->__soapCall("Dispatch", 
array($username, $password,
"TicketObject", "TicketSearch",
"CustomerUserID", "some_customers_login",
));
[/code]

One additional thing to note.  Both of the last two functions return arrays of values, rather than a single value.  You might want to look at my post about how to parse the values into a usable array.

Jeff Eske

SEE ALSO:
OTRS – Simple Web Service Example Using PHP,

PHP Script to Display SOAP Requests and Responses,

OTRS – TicketGet() Web Service Example in PHP

2 Comments

  1. Hi Jeff,

    I am working with OTRS version 3.3.8 and got a task to create/update/search a ticket using Web services. I imported the new generic interface web service in OTRS and got a perl script for creating a ticket through it but couldn’t get the correct perl or PHP script for update and search functions. The issue I am facing with the php scripts used on various web sites is making use of old rpc.pl web services and I still couldn’t figure out how to make use of this rpc.pl web service and further PHP scripts to actually update and search a ticket in OTRS.
    Please let me know the correct procedure for using these php scripts.

    Thanks & Regards,
    Vivek

    Comment by Vivek garg — July 7, 2014 @ 10:06 am
  2. Hello Vivek,

    I’m sorry, but I changed jobs some time ago and don’t work with OTRS anymore, so I can’t really help you. It’s been over a year now since I’ve worked with it at all, so my recollection of how to set it up is pretty dim. I would recommend that you look into the OTRS forums at: http://forums.otterhub.org/. They were very helpful for me.

    Sorry I can’t be of more help.

    Good luck.

    Jeff

    Comment by Jeff Eske — July 7, 2014 @ 10:25 am

RSS feed for comments on this post.

Sorry, the comment form is closed at this time.

This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 2.5 License. | Jeff's Blog