REST Interface for Creating Ticket?

Hi -
I would like to integrate a customer self-service extranet with RT using
the REST interface. Customers need to be able to submit a new ticket &
view their existing tickets.

I’m able to query a user’s tickets fine. However, I can’t seem to create
a ticket using the REST interface (yes, I know I can send it via email
or use CLI … but I would like to keep this all w/in REST if possible).

Here is the syntax I’ve tried (along with several variations):
$RTBASE/REST/1.0/ticket/new?user=xxxx&pass=xxxx&queue=General&text=text&subject=Subject

I get the following response:

RT/3.6.5 200 Ok

Required: id, Queue

id: ticket/new
Queue: General
Requestor: mmelson
AdminCc:
Owner: Status: new
Priority: 0
InitialPriority: 0
FinalPriority: 0
TimeEstimated: 0
Starts: 2008-11-30 22:27:25
Due: 2008-11-30 22:27:25
Text:
Any suggestions?
Thanks,
M2

1 Like

If you are using Perl, there is a library available: RT-Client-REST-0.72 - Client for RT using REST API - metacpan.org

  • Dmitri.----- Original Message ----

From: Mike Melson Mike.Melson@Caringo.com
To: rt-devel@lists.bestpractical.com
Sent: Sunday, November 30, 2008 9:48:07 PM
Subject: [Rt-devel] REST Interface for Creating Ticket?

Hi -
I would like to integrate a customer self-service extranet with RT using
the REST interface. Customers need to be able to submit a new ticket &
view their existing tickets.

I’m able to query a user’s tickets fine. However, I can’t seem to create
a ticket using the REST interface (yes, I know I can send it via email
or use CLI … but I would like to keep this all w/in REST if possible).

Here is the syntax I’ve tried (along with several variations):
$RTBASE/REST/1.0/ticket/new?user=xxxx&pass=xxxx&queue=General&text=text&subject=Subject

I get the following response:

RT/3.6.5 200 Ok

Required: id, Queue

id: ticket/new
Queue: General
Requestor: mmelson
Subject: Cc:
AdminCc:
Owner: Status: new
Priority: 0
InitialPriority: 0
FinalPriority: 0
TimeEstimated: 0
Starts: 2008-11-30 22:27:25
Due: 2008-11-30 22:27:25
Text:
Any suggestions?
Thanks,
M2


List info: The rt-devel Archives

Thanks Dmitri. Unfortunately, I have to use PHP.

Dmitri Tikhonov wrote:

A POST would be fine. (I actually did try a simple form but got the same
response). Thanks!

Frank F. Smith wrote:

Mike Melson wrote:

Thanks Dmitri. Unfortunately, I have to use PHP.
How about creating an HTTP POST with multi-part form content? If that
works for you, I might be able to help a bit. (I need to create and edit
tickets from C# code in .Net and have worked out some of the content model.)

Frank

Dmitri Tikhonov wrote:

If you are using Perl, there is a library available: RT-Client-REST-0.72 - Client for RT using REST API - metacpan.org

  • Dmitri.

----- Original Message ----

From: Mike Melson Mike.Melson@Caringo.com
To: rt-devel@lists.bestpractical.com
Sent: Sunday, November 30, 2008 9:48:07 PM
Subject: [Rt-devel] REST Interface for Creating Ticket?

Hi -
I would like to integrate a customer self-service extranet with RT using
the REST interface. Customers need to be able to submit a new ticket &
view their existing tickets.

I’m able to query a user’s tickets fine. However, I can’t seem to create
a ticket using the REST interface (yes, I know I can send it via email
or use CLI … but I would like to keep this all w/in REST if possible).

Here is the syntax I’ve tried (along with several variations):
$RTBASE/REST/1.0/ticket/new?user=xxxx&pass=xxxx&queue=General&text=text&subject=Subject

I get the following response:

RT/3.6.5 200 Ok

Required: id, Queue

id: ticket/new
Queue: General
Requestor: mmelson
Subject: Cc:
AdminCc:
Owner: Status: new
Priority: 0
InitialPriority: 0
FinalPriority: 0
TimeEstimated: 0
Starts: 2008-11-30 22:27:25
Due: 2008-11-30 22:27:25
Text:
Any suggestions?
Thanks,
M2

Frank F. Smith

PESTICIDE SALES AND USE REPORTING DATABASE GROUP
20 THORNWOOD DR STE 106
ITHACA NY 14850-1265

Email: ffs1@cornell.edu
Phone: (607) 257-5706

Mike Melson wrote:

A POST would be fine. (I actually did try a simple form but got the
same response). Thanks!
OK. Here’s a simple example. Here, the boundary string xYzZY is some
more-or-less random alphanumeric string that does not appear anywhere in
the form data.

Send an HTTP POST request to the URI
$RTBASE/REST/1.0/edit?user=xxxx&pass=xxxx
(You can also use an authentication cookie received from a previous request)
ContentType: multipart/form-data; boundary=“xYzZY”
ContentLength: set based on content below

Content of the POST looks something like:
–xYzZY
Content-Disposition: form-data; name=“content”

id: ticket/new
queue: General
subject: Creating a new ticket
requestors: me@somewhere.net

–xYzZY–

Note that the HTTP Response will almost always have a status code of 200
“OK”. The first line of the response content includes a status code, but
it is also likely to be 200 OK, even if the create request failed. But
that’s another issue…

Hope this helps,
Frank

Frank F. Smith wrote:

Mike Melson wrote:

Thanks Dmitri. Unfortunately, I have to use PHP.
How about creating an HTTP POST with multi-part form content? If that
works for you, I might be able to help a bit. (I need to create and
edit tickets from C# code in .Net and have worked out some of the
content model.)

Frank

Frank F. Smith

PESTICIDE SALES AND USE REPORTING DATABASE GROUP
20 THORNWOOD DR STE 106
ITHACA NY 14850-1265

Email: ffs1@cornell.edu
Phone: (607) 257-5706

Tim Coles wrote:

I think simple forms fail because the REST interface is quite particular
about carriage return/line feed combinations. IIRC it requires a CF/LF
between each http field but within the http field called “content”
(where you pass it all of your ticket fields) it will just accept a \n
between each one. Something like that anyway.

Either way having or not having the right combination was the difference
between success and failure for me on several occasions (and was the
main problem our .NET devs had when doing their test forms).

Sounds about right to me, though I’ve not tested all the combinations.

Mike: In the sample content I sent moments ago, I failed to note that
what I am sending (based on my understanding of the RT::Client::REST
modules) has CrLf after each line except the field: value lines, which
all end with just Lf.

Frank

Tim

Frank F. Smith

PESTICIDE SALES AND USE REPORTING DATABASE GROUP
20 THORNWOOD DR STE 106
ITHACA NY 14850-1265

Email: ffs1@cornell.edu
Phone: (607) 257-5706

Success!

Based on the comments in this thread, I was able to use the following
HTML form to create a new ticket:

User:
Pass:
Content: id: new Text: This is the ticket text Queue: General

Interestingly, the Queue field had to be at the end of the list or it
didn’t work.

Thanks again for the excellent help! I’ll start the integration via php
using the code Tim supplied (thanks Tim!)

M2

Frank F. Smith wrote: