[rt-users] Need to "edit" a ticket via javascript and Angular.js $http.post

Keith Creasy kcreasy at aph.org
Mon May 16 13:39:07 EDT 2016


Hello all.


I'm using RT 4.2.7.


I have my RT progress page working. I solved my previous problem of RT altering attribute values that were needed by Angular by redirecting so that the actual report page lives outside RT. One can now to to the URL, log into RT, and view the project progress report.


Now I want to update RT with some calculated values on certain, what we are calling "epic", tickets. The documentation is pretty vague and so far I haven't found just the right way to make it work. Does anyone have a good, working example of a call to edit an RT ticket via Javascript, or even better Angular.js? Here is my function as it currently stands. There is a lot of variable declarations that I probably don't need but was trying to rule out what might have been my own mistakes.


// We want to set the actual values in RT to match our calclulations on Epics.
this.setTimeData = function ( row) {
var number = row.id;
var url = baseURL+"ticket/"+row.id+"/edit";
var timeWorked = row.TimeWorked*60;
var timeLeft = row.TimeLeft*60;
var data = [];
data['content'] = 'TimeWorked: '+timeWorked+'\nTimeLeft: '+timeLeft;
if( number == 3683) {
console.log( url+": "+data.content+".");
$http.post( url, data)
.then( function (response) {
console.log(response.data);
})
.catch( function (e) {
console.log(e);
});
}
}



The response I get just has the ticket details in the response data... No errors but the ticket doesn't get updated either.


Thank yu for any assistance.


Keith


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bestpractical.com/pipermail/rt-users/attachments/20160516/9f96f74c/attachment.htm>


More information about the rt-users mailing list