OTRS REST Java Client

heaphach picture heaphach · Feb 17, 2015 · Viewed 7.3k times · Source

Does someone knows a good java client for OTRS or can me point to some info pages for writing my own client? I am totally new to OTRS, but I had heard there is an external interface (Webservice) to do most of the OTRS work with java REST clients.

Can someone link some info pages? Perhaps an example how to create REST WS with OTRS with some curl examples how to use it?

Already found links:

  1. https://github.com/gtudan/OTRS-Client --> maintenance level is low
  2. https://www.otrs.com/otrs-help-desk-software-unterstuetzt-jetzt-rest/?lang=de
  3. http://otrs.github.io/doc/manual/admin/stable/en/html/genericinterface.htmls
  4. ...

I created a webservice with this yaml file:

---
Debugger:
  DebugThreshold: debug
  TestMode: '0'
Description: The description of WS
FrameworkVersion: 4.0.5
Provider:
  Operation:
    TicketGet:
      Description: ''
      MappingInbound:
        Type: Simple
      MappingOutbound:
        Type: Simple
      Type: Ticket::TicketGet
  Transport:
    Config:
      KeepAlive: ''
      MaxLength: '20000000'
      RouteOperationMapping:
        TicketGet:
          Route: /Ticket/:TicketID
    Type: HTTP::REST
RemoteSystem: ''
Requester:
  Transport:
    Type: ''

Then I try to curl to WS:

curl -i -H "Content-Type: application/json" -d {UserLogin:"user",Password="userpass",Ticket={Title="test"}} http://localhost/otrs/nph-genericinterface.pl/Webservice/Test/Ticket/1

But it does not work.

Answer

heaphach picture heaphach · Feb 24, 2015

First of all it is important how you name your Webservice. I choose 'Test'. Import this yml or create your own WS, export config yml and change it to the following below. Save changes and reimport this file.

---
Debugger:
  DebugThreshold: debug
  TestMode: '0'
Description: Is used by me
FrameworkVersion: 4.0.5
Provider:
  Operation:
    TicketGet:
      Description: ''
      MappingInbound:
        Type: Simple
      MappingOutbound:
        Type: Simple
      Type: Ticket::TicketGet
    TicketUpdate:
      Description: ''
      MappingInbound:
        Type: Simple
      MappingOutbound:
        Type: Simple
      Type: Ticket::TicketUpdate
  Transport:
    Config:
      KeepAlive: ''
      MaxLength: '20000000'
      RouteOperationMapping:
        TicketGet:
          Route: /TicketGet/:TicketID
        TicketUpdate:
          RequestMethod:
          - POST
          Route: /TicketUpdate/:TicketID
    Type: HTTP::REST
RemoteSystem: ''
Requester:
  Transport:
    Type: ''

Then check that ticket with ticketID 1 exists with some example title like "first Title".

Then use this curl:

curl -X POST -i -H "content-type: application/json" -d '{"UserLogin": "user", "Ticket": {"Title": "changeme"}, "Password": "userpass"}' "http://localhost/otrs/nph-genericinterface.pl/Webservice/Test/TicketUpdate/1"

If you name your WS like "Test123xy", then rename the curl url

".../Webservice/Test/..." 

to

".../Webservice/Test123xy/..."

Now it works for me.