[rt-users] Creating ticket through REST API with AJAX
Brian C. Duggan
brian at dugga.net
Thu May 29 10:54:39 EDT 2014
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: requestor at 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
More information about the rt-users
mailing list