Passella Passella - 4 months ago 69
reST (reStructuredText) Question

OTRS + REST + TicketCreate

I am have difficulties to implement the REST service for Ticket Creation with OTRS, I already integrate TicketGet and TicketUpdate services with my system, but can't integrate with the TicketCreate service.

yml file:

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


Request:

{
"UserLogin":"web.service",
"Password":"********",
"Ticket":{
"Title":"Title",
"QueueID":"61",
"LockID":"2",
"TypeID":"1",
"ServiceID":"",
"SLAID":"",
"StateID":"63",
"PriorityID":"3",
"CustomerUser":"user@email.com.br"
},
"Article":{
"ArticleTypeID":"8",
"SenderTypeID":"1",
"From":"User <user@email.com.br>",
"Subject":"WebService Proc Linner Teste",
"Body":"Teste WebService",
"ContentType":"text/plain",
"MimeType":"text/plain",
"Charset":"UTF8"
}
}


Return:

{
"Error":
{
"ErrorCode":"TicketCreate.InvalidParameter",
"ErrorMessage":"TicketCreate: Article->ContentType is invalid!"
}
}


what is a valid ContentType ?

Can someone help me?

Answer

Ticket and Article need to be objects at the same level. And, as pointed out by @TOndrej, you're passing some attributes that do not exist for Article. Please find a minimal data sample below:

{
   "Ticket" : {
      "Queue" : "Raw",
      "Priority" : "3 normal",
      "CustomerUser" : "max",
      "Title" : "REST Create Test",
      "State" : "open",
      "Type" : "Unclassified"
   },
   "Article" : {
      "ContentType" : "text/plain; charset=utf8",
      "Subject" : "Rest Create Test",
      "Body" : "This is only a test"
   }
}
Comments