Rest Create Ticket - Request sample Please?

English! place to talk about OTRS development, programming and coding
Post Reply
Amukinado
OTRS expert
Posts: 76
Joined: 02 Jun 2010, 15:52
OTRS Version?: 3.2.8
Location: Portugal

Rest Create Ticket - Request sample Please?

Post by Amukinado » 21 May 2019, 12:43

Hi. Back to OTRS after 2 years away, I'm tryinbg to create a ticket via REST, on 6.0.

I imported the .yml file and I'm looking at the debug page, but can't figure out what's wrong. I can get the sample ticket created upon install, but can't form a valid request to create a ticket. I'm posting my request. Auth is beeing sent in params, request is going in body as raw. Also tryed it as form-data but with no sucess either. I'm using postman. And yes, I've been reading the doc's, that's where I started. Also looked for a post with an example, but that got me nowhere... This was the most usefull post, but still got me a few steps in the direction, but not to results. Here is my request and pic's. Sorry to bother, I've been trying this since yesterday and getting no results. And yes, I'm not a JSON expert, yet! :D

Request:

Code: Select all

{"Ticket":[{
"Title":"REST Create Test",
 "Queue":"Raw",
 "State":"new",
 "Priority":"3 normal"
 }],
 "Article":[{
 "CommunicationChannel":"Email",
 "Subject":"Rest Create Test",
 "Body":"This is only a test",
 "ContentType":"text/plain"
 }]
 }
Thanks in advance, Regards.

Image
You do not have the required permissions to view the files attached to this post.
OTRS V3.2.8 - ITSM 3.2.6 - Cent OS 5.9x64

Amukinado
OTRS expert
Posts: 76
Joined: 02 Jun 2010, 15:52
OTRS Version?: 3.2.8
Location: Portugal

Re: Rest Create Ticket - Request sample Please?

Post by Amukinado » 21 May 2019, 17:20

Solved:

Had to create a Customer and a Customer User because it was mandatory... Is there anyway to make it non mandatory? BTW, it wasn't the problem. The problem was with the JSON resquest formating.

Code: Select all

{
  "Ticket" : 
  {
    "Title": "Test Title",
    "Queue": "Raw",
    "Lock": "unlock",
    "Type": "Unclassified",
    "State": "new",
    "Priority": "3 normal",
    "CustomerUser": "restapi"
  },

  "Article":
  {
    "Subject" : "Test Subject(Article)",
    "Body" : "BODY (Article)",
    "ContentType": "text/plain; charset=utf8"       

  }
}
Hope this helps anyone in the future. Regards
OTRS V3.2.8 - ITSM 3.2.6 - Cent OS 5.9x64

Post Reply