Create ticket via REST API with a content


#1

Hi,

I use the REST API 2.0 and try to create a ticket with a text.
I create a ticket with the POST method and a JSON content, but I don’t understand which key I have to use to add a text.

For example, today my JSON content seems like :
{
“Queue”:“My Queue”,
“Subject”:“Subject of the ticket”,
“Status”:“new”
}

I tried with the key “Text” and “Content”, but nothing works.

Thanks for your help.


#2

Hi,

The key is ‘Text’. Here’s a snippet of PHP code I use. The variable $msg contains the body. Note the comment I’m including about continuation lines needing to begin with spaces.

  /* RT content with newlines must have spaces at beginning of
   subsequent lines */
  $rtcontent['Text'] = preg_replace("/\n/", "\n ", $msg);
  $rtresponse = $rt->createTicket($rtcontent);

Hope this helps,

-Rob McNicholas
UC Berkeley


#3

@Robert_McNicholas From your code you’re using REST 1.0, @hannii33 is referring to REST 2.0

I’m facing exactly the same problem, the initial Content is not saved upon Ticket creation with REST 2.0.


#4

You can see examples on ticket create for REST2 here:

The key, in this case, is Content.


#5

It doesn’t work for me, I ended up creating a comment with the initial content.

The examples also show that you can reference custom fields by name and that doesn’t work either