REST API

Moderator: crythias

Locked
tinti
Znuny newbie
Posts: 11
Joined: 24 Oct 2016, 16:16
Znuny Version: 5.0.14
Real Name: Raoul

REST API

Post by tinti »

Hi,

I need some help with the REST API. The only service which I can use is SessionCreate, all other services result in error: HTTP::REST Error while determine Operation for request URI.

Maybe I am using the API not correctly? Below is my configuration, I removed some stuff to make it smaller:

Code: Select all

---
Debugger:
  DebugThreshold: debug
  TestMode: '0'
Description: REST API v1
FrameworkVersion: 4.0.2
Provider:
  Operation:
    ConfigItemGet:
      Description: Retrieves ConfigItem data
      MappingInbound: {}
      MappingOutbound: {}
      Type: ConfigItem::ConfigItemGet
    SessionCreate:
      Description: Creates a Session
      MappingInbound: {}
      MappingOutbound: {}
      Type: Session::SessionCreate
  Transport:
    Config:
      KeepAlive: ''
      MaxLength: '100000000'
      RouteOperationMapping:
        ConfigItemGet:
          RequestMethod:
          - GET
          Route: /ConfigItemGet:ConfigItemID
        SessionCreate:
          RequestMethod:
          - POST
          Route: /Session
    Type: HTTP::REST
RemoteSystem: ''
Requester:
  Transport:
    Type: ''
The call to create a new session results in a SessionID:

Code: Select all

POST /otrs/nph-genericinterface.pl/Webservice/APIv1/Session HTTP/1.1
Host: otrs.example.com
Accept-Encoding: gzip, deflate
Connection: close
Accept: */*
Content-Type: application/json
Content-Length: 63

{"Password": "password", "UserLogin": "username"}

Code: Select all

GET /otrs/nph-genericinterface.pl/Webservice/APIv1/ConfigItemGet/1234 HTTP/1.1
Host: otrs.example.com
Accept-Encoding: gzip, deflate
Connection: close
Accept: */*
Content-Type: application/json
Content-Length: 72

{"SessionID": "xxx", "ConfigItemID": 1234}
HTTP::REST Error while determine Operation for request URI '/ConfigItemGet/1234'

I tried already other queries like TicketGet or ConfigItemSearch and TicketSearch, but all result in the same HTTP::REST error.

Any ideas?

Thanks.
tinti
Znuny newbie
Posts: 11
Joined: 24 Oct 2016, 16:16
Znuny Version: 5.0.14
Real Name: Raoul

Re: REST API

Post by tinti »

Found the error, was the web service configuration.

Correct yaml config looks like:

Code: Select all

Debugger:
  DebugThreshold: debug
  TestMode: '0'
Description: REST API v1
FrameworkVersion: 4.0.2
Provider:
  Operation:
    ConfigItemGet:
      Description: Retrieves ConfigItem data
      MappingInbound: {}
      MappingOutbound: {}
      Type: ConfigItem::ConfigItemGet
    SessionCreate:
      Description: Creates a Session
      MappingInbound: {}
      MappingOutbound: {}
      Type: Session::SessionCreate
  Transport:
    Config:
      KeepAlive: ''
      MaxLength: '100000000'
      RouteOperationMapping:
        ConfigItemGet:
          RequestMethod:
          - GET
          Route: /ConfigItem/:ConfigItemID
        SessionCreate:
          RequestMethod:
          - POST
          Route: /Session
    Type: HTTP::REST
RemoteSystem: ''
Requester:
  Transport:
    Type: ''
Note the changed route.
Locked