[rt-users] Creating ticket through REST API with AJAX

2014-05-29 Thread Brian C. Duggan
Hi,

I'm trying to create a ticket through the REST interface via an AJAX request. 
Here's my code so far...

var fields = 'id: ticket/new\n\
Queue: Texas\n\
Requestor: reques...@rt.myrtsrv.com\n\
Subject: Yet another REST ticket\n\
Cc: \n\
AdminCc: \n\
Owner: \n\
Status: new\n\
Priority: \n\
InitialPriority: \n\
FinalPriority: \n\
TimeEstimated: \n\
Starts: 2014-05-28 18:01:53\n\
Due: 2014-05-28 18:01:53\n\
Text: Yet another REST ticket';

jQuery(document).ready( function() {
var formData = new FormData();
formData.append( 'content', fields );

$.ajax({
type: 'POST',
url: 'https://rt.myrtsrv.com/REST/1.0/edit',
data: formData,
processData: false,
contentType: false,
success:function(data){
$(#ajax-panel).append(pre+data+/pre);
}
});
});

The server returns this respsonse:

RT/4.2.3 400 Bad Request

# Ticket new
 does not exist.

I've tried the same method with the rt command line tool, and it succeeds.

I can paste in the request headers and POST data this generates if it's not 
obvious what I'm doing wrong.

Thanks,
Brian
-- 
RT Training - Boston, September 9-10
http://bestpractical.com/training


Re: [rt-users] Creating ticket through REST API with AJAX

2014-05-29 Thread Brian C. Duggan
On Thu, May 29, 2014 at 01:58:48PM -0400, Jim Brandt wrote:
jQuery(document).ready( function() {
  var formData = new FormData();
  formData.append( 'content', fields );
 
  $.ajax({
  type: 'POST',
  url: 'https://rt.myrtsrv.com/REST/1.0/edit',
 
 Maybe call new instead of edit?
 
 https://rt.myrtsrv.com/REST/1.0/ticket/new
 

Thanks, Jim. I should have checked the wiki. Progress, but now the server 
replies

RT/4.2.3 200 Ok

# Could not create ticket.
# Could not create ticket. Queue not set

The user has all 'Modify' rights on the queue directly, not through a group. I 
can tell that RT is consuming all the headers because RT logs the 'Starts' and 
'Due' fields.

Any suggestions appreciated.

Thanks,
Brian
-- 
RT Training - Boston, September 9-10
http://bestpractical.com/training